Created
December 20, 2022 16:19
-
-
Save acoster/7075cb132c317670d4ceee6416310b78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pytwitter | |
import time | |
import os | |
import sys | |
import schedule | |
from schedule import every, repeat, run_pending | |
twitter_conn = None | |
@repeat(every(15).seconds) | |
def detect_ban(): | |
global twitter_conn | |
account_name = os.getenv('WATCHED_USER') | |
try: | |
twitter_conn.get_user(username=account_name) | |
except pytwitter.error.PyTwitterError as err: | |
print("%s: %s has been banned" % (time.asctime(), account_name)) | |
sys.exit(0) | |
if __name__ == '__main__': | |
twitter_conn = pytwitter.Api(os.getenv('TWITTER_TOKEN')) | |
while True: | |
run_pending() | |
time.sleep(schedule.idle_seconds()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment