From f01289c6c487bf620762d61394f5d069d71322e0 Mon Sep 17 00:00:00 2001 From: robin Date: Sun, 22 May 2022 14:16:12 +0200 Subject: [PATCH] Add Tweepy --- main.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..9b64f08 --- /dev/null +++ b/main.py @@ -0,0 +1,50 @@ +from settings import * +from mastodon import Mastodon +from os.path import exists +import tweepy +def main(): + if not exists(app_path): + Mastodon.create_app( + bot_name, + api_base_url = api_url, + to_file = app_path + ) + + if not exists(user_path): + mastodon = Mastodon( + client_id = app_path, + api_base_url = api_url + ) + mastodon.log_in( + account_name, + account_password, + to_file = user_path + ) + mastodon_api = Mastodon( + access_token = user_path, + api_base_url = api_url + ) + mastodon_user = mastodon_api.account_verify_credentials() +# auth = tweepy.OAuthHandler( +# twitter_auth_keys['consumer_key'], +# twitter_auth_keys['consumer_secret'] +# ) +# auth.set_access_token( +# twitter_auth_keys['access_token'], +# twitter_auth_keys['access_token_secret'] +# ) +# twitter_api = tweepy.API(auth) + twitter_api = tweepy.Client( + consumer_key = twitter_auth_keys['consumer_key'], + consumer_secret = twitter_auth_keys['consumer_secret'], + access_token = twitter_auth_keys['access_token'], + access_token_secret = twitter_auth_keys['access_token_secret'] + ) + print(twitter_api.get_me()) + timeline = mastodon_api.account_statuses(mastodon_user,exclude_replies=True) + for toot in timeline: + if(toot.visibility == 'public' and toot.account.id == mastodon_user.id and not toot.reblog): + print(toot) + #print(timeline) +if __name__ == "__main__": + main() \ No newline at end of file