Skip to content

Instantly share code, notes, and snippets.

@hclivess
Created August 3, 2020 21:22
Show Gist options
  • Save hclivess/1ae01370b0a153ecb4c60f246ecab829 to your computer and use it in GitHub Desktop.
Save hclivess/1ae01370b0a153ecb4c60f246ecab829 to your computer and use it in GitHub Desktop.
import os
import time
import tweepy
import logging
import glob
import json
import random
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger("ft_rest_client")
run_interval = 86400
def tweet():
print("Tweeting...")
auth = tweepy.OAuthHandler(api_key, api_secret_key)
auth.set_access_token(access_token, access_token_secret)
api = tweepy.API(auth)
# composed.append(f"Profit open: {int(output_profit['profit_all_coin'])} USDT ({percentage(output_profit['profit_all_coin'], starting_capital)}%)")
# composed.append(f"Profit closed: {int(output_profit['profit_closed_coin'])} USDT ({percentage(output_profit['profit_closed_coin'], starting_capital)}%)")
files = glob.glob("sonety/*")
file = random.choice(files)
name = f"Sonet {os.path.basename(file).split('.')[0]}"
api.update_with_media(file, name)
if __name__ == "__main__":
with open("config.json") as config_file:
config = json.loads(config_file.read())
api_key = config["api_key"]
api_secret_key = config["api_secret_key"]
access_token = config["access_token"]
access_token_secret = config["access_token_secret"]
while True:
try:
tweet()
print(f"Sleeping for {run_interval/60} minutes")
except Exception as e:
print(f"An error occurred: {e}, skipping run")
time.sleep(run_interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment