From 18a9b706b001dce8e3859f643503c02d950e7439 Mon Sep 17 00:00:00 2001 From: b3yond Date: Sat, 17 Jun 2017 22:32:20 +0200 Subject: [PATCH] troubleshooting --- last_mention | 1 - retweetbot.py | 26 +++++++++++++++----------- trigger.py | 2 +- trigger.pyc | Bin 0 -> 1914 bytes 4 files changed, 16 insertions(+), 13 deletions(-) delete mode 100644 last_mention create mode 100644 trigger.pyc 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 0000000000000000000000000000000000000000..881b29b1e3319828ed8e0d7b7a18558d694a42e4 GIT binary patch literal 1914 zcmbtUQEwYX5T3oW-P)wIM1lu+U|$f1v^I!03!y>*2?<5&*;3j_?dg2Cw$DB9I=Ab% zm7J&a9iDjNFY#;m1AH^SB&rY+lteq;-J6-6neUs4|Gd*X`t^sWIW>PVejj4_&mamS zLo`!VD0)qFN%Ztok%_2?=tV^JCuE@%)41P)cDMyGsmuA?)NlCvj{OZG;0*TgdI}fV zK*sbsqSKg)7Qb-XqM|LEHYMYJhYcS>^fdk^i_+`7%DmU>+MSn$@jBD9vI?fw!RcUp zz=aQWY3DkdXQlOFAg19qoXnjos?rCEbDGIMkMW_6#R`wG{BICDMLVJtDPbeoUqP+4vqQRQ(XK_yn9t86I_ryNi%yW`<0rdFj%{%yIsa=%XJXlD9KqYT zA0f13&$2%1bFsq##8q1BEG$9`7jA8A=(3jKBrVFq8FF3LiNY?t1JM+KtrB+GXC1Nk zrkW*OmqgxRix~<54}Ay{;XlQ0xNs{ooPPDn*uOsP56r z&qXPQ(#QXxG~~3#XG1zc9mZ!p{Nmh~jQ+qo!Vo4{zA*UTK1x8R>8JygWCyIS=$?YfR9t))VK#eX!bO z))abHyOmyqRkf!r2Q{iq*wl8Uf12sAFjs-C(FWi@-!Sj5-<6)(qs)L-Zfj~mbynI! zfEF_Rm{s1${iNQQKG!~BXo9qybda#5L6OsbOYj+MDQvoL%=d8i??TY6d+L3~>o)$S z5&3amLV;)40OtCzVF8-Yc4e=)5d%nou>nG$H6OguhZk+ywP}gY#8*X%8&t0NaDu7x z_zA>Vvi85@nZLot`HpT_;FuA7r?-nTUueH@o2t-Lqq8-dtpIYEKh7ErO@@TWjK9XD z;lk88hI#LUHAeaiJreft={}e=Vv_OU27l?i?eQL0!HK&v;Z8}UWw~JcFhUR8ZCwT< zUB5RGR9Tzjm$4u@@FRl13;>=Mft|bRZE@zAvRM~dFe&@iIPPKYbku=#`GLBlB&KE{ z*lcCeRDw>^l`A$CA33`;EnJ?a3HwYAS$qg_LqOU6ml2e}T!xG1a&+R3y4&sEZQ@v= l!PE3u=pg)e)1}FS*d!nQzlY_CulLD)!zg$b9~>R1zW|U9pP2vv literal 0 HcmV?d00001