diff --git a/last_mention b/last_mention deleted file mode 100644 index 35d3afd..0000000 --- a/last_mention +++ /dev/null @@ -1 +0,0 @@ -876122799538147328 \ No newline at end of file diff --git a/retweetbot.py b/retweetbot.py index 03fc4f0..c13dabc 100644 --- a/retweetbot.py +++ b/retweetbot.py @@ -39,8 +39,8 @@ class RetweetBot(object): self.triggerpath = triggerpath self.user_id = user_id self.screen_name = screen_name - self.last_mention = bot.get_history(self.historypath) - self.triggers = bot.get_trigger(self.triggerpath) + self.last_mention = self.get_history(self.historypath) + self.triggers = self.get_trigger(self.triggerpath) self.trigger = trigger def get_api_keys(self, path): @@ -70,8 +70,12 @@ class RetweetBot(object): :param path: string: contains path to the file where the ID of the last_mention is stored. :return: last_mention: ID of the last tweet which mentioned the bot """ - with open(path, "r+") as f: - last_mention = f.read() + try: + with open(path, "r+") as f: + last_mention = f.read() + except IOError: + with open(path, "w+"): + last_mention = "" return last_mention def get_trigger(self, path): @@ -161,7 +165,7 @@ class RetweetBot(object): # save the id so it doesn't get crawled again self.last_mention = status.id - print self.last_mention + print self.last_mention # debug # Return Retweets for tooting on mastodon return mastodon @@ -173,11 +177,11 @@ class RetweetBot(object): self.api.PostDirectMessage("Help! I broke down. restart me pls :$", self.user_id, self.screen_name) -if __name__ == "main": +if __name__ == "__main__": # create an Api object bot = RetweetBot() - try: - while True: - bot.flow() - except: - bot.shutdown() + while True: + sleep(1) + bot.flow() + #except: + # bot.shutdown() diff --git a/trigger.py b/trigger.py index 64c5bc9..78e6969 100644 --- a/trigger.py +++ b/trigger.py @@ -44,5 +44,5 @@ class Trigger(object): old.append(word) f.writelines(old) -if __name__ == "main": +if __name__ == "__main__": pass diff --git a/trigger.pyc b/trigger.pyc new file mode 100644 index 0000000..881b29b Binary files /dev/null and b/trigger.pyc differ