From 1e91c9dda09565ad78b84c76ae966b17c1c555c6 Mon Sep 17 00:00:00 2001 From: Oussama Rafouk <156216265+ocryptocode@users.noreply.github.com> Date: Tue, 2 Jul 2024 12:01:47 +0100 Subject: [PATCH] Update twitterapp.py Add more comments and more documentation --- Twitter-Bot/twitterapp.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Twitter-Bot/twitterapp.py b/Twitter-Bot/twitterapp.py index 758acf3..0775c0b 100644 --- a/Twitter-Bot/twitterapp.py +++ b/Twitter-Bot/twitterapp.py @@ -1,3 +1,4 @@ +# import necessary modules import tweepy from time import sleep from credientials import * @@ -5,11 +6,13 @@ import datetime +# setup credentials auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) +# print twitter messages print("Twitter bot which retweets, like tweets, follow users and post daily tweets") print("Bot Settings") print("Retweet Tweets :{message}".format( @@ -21,10 +24,12 @@ print("Every day tweets :{message}".format( message="Enabled" if EVERYDAY_TWEETS else "Disabled")) +# create the tweet loop for tweet in tweepy.Cursor(api.search, q=QUERY).items(): try: print('\nTweet by: @' + tweet.user.screen_name) + # repost the tweet if RETWEET: tweet.retweet() print('Retweeted the tweet')