def on_scheduled_tweet(self): text = gen() if os.path.exists("resources/tweeted.txt"): tweeted = list(open("resources/tweeted.txt", "r").read().split()) while text in tweeted: text = gen() self.post_tweet(text.decode("utf-8")) with open("resources/tweeted.txt", "a") as fp: fp.write(text + "\n")
def on_mention(self, tweet, prefix): tweet_time = tweet.created_at # tweet timestamp now = datetime.datetime.utcnow() diff = now - tweet_time # tweet age text = gen() # only reply to mentions in last 2 mins if diff.seconds <= 120: if "request bandname" in tweet.text: # TODO not ideal self.post_tweet(prefix + ' ' + text, reply_to=tweet)