import threading from datetime import datetime import time from app_be.models import Tweet from app_be.views.twitter_api import twitter_api class twitter_bot(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): while True: # Search RSS Feeds TODO: for looping over feeds print("Looking for new results in active feeds") new_tweet = Tweet() new_tweet.icon = None new_tweet.text = "Test 2" new_tweet.date_time = datetime.now() new_tweet.url = "www.google.com" # if tweet not in db yet if Tweet.objects.filter(text=new_tweet.text) == []: # call twitter api to post tweet and store to db print("Posting update on Twitter") twitter_api.post_update(new_tweet.text, new_tweet.url) new_tweet.save() time.sleep(60)