From f0f5d91813372741d30139ee1608c16a34df751a Mon Sep 17 00:00:00 2001 From: b3yond Date: Sun, 18 Jun 2017 00:35:34 +0200 Subject: [PATCH] fixing stuff --- README.md | 8 ++++++++ badlist | 1 - retootbot.py | 2 +- retweetbot.py | 8 ++++++-- ticketfrei.cfg.example | 8 ++++++++ trigger.py | 6 ++++-- trigger.pyc | Bin 1914 -> 2006 bytes 7 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dbbdd77..91b1e3e 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,14 @@ Install dependencies $ pip3 install Mastodon.py pytoml pickle $ pip install python-twitter pytoml requests ``` +Configure +```shell +$ cp ticketfrei.cfg.example ticketfrei.cfg +$ vim ticketfrei.cfg +``` +Edit the account credentials, so your bot can use your accounts. + +Also ## ideas diff --git a/badlist b/badlist index 164c0cd..f732a93 100644 --- a/badlist +++ b/badlist @@ -6,5 +6,4 @@ jude schwuchtel fag faggot -arbeitsplätze diff --git a/retootbot.py b/retootbot.py index 9a11e59..ca0a110 100644 --- a/retootbot.py +++ b/retootbot.py @@ -45,7 +45,7 @@ class RetootBot(object): self.config['muser']['password'] ) - def retoot(self, toots=[]): + def retoot(self, toots=()): # toot external provided messages for toot in toots: self.m.toot(toot) diff --git a/retweetbot.py b/retweetbot.py index c13dabc..6ce1b17 100644 --- a/retweetbot.py +++ b/retweetbot.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +__encoding__ = "utf-8" import twitter import requests @@ -105,6 +106,9 @@ class RetweetBot(object): try: mentions = self.api.GetMentions(since_id=self.last_mention) return mentions + except twitter.TwitterError: + print("[ERROR] Rate Limit exceeded, trying again once a minute") + sleep(60) except requests.exceptions.ConnectionError: print("[ERROR] Bad Connection.") sleep(10) @@ -118,7 +122,7 @@ class RetweetBot(object): """ while 1: try: - self.api.PostRetweet(status.id) + print self.api.PostRetweet(status.id) return self.format_mastodon(status) # Hopefully we got rid of this error. If not, try to uncomment these lines. # except twitter.error.TwitterError: @@ -181,7 +185,7 @@ if __name__ == "__main__": # create an Api object bot = RetweetBot() while True: - sleep(1) + sleep(10) bot.flow() #except: # bot.shutdown() diff --git a/ticketfrei.cfg.example b/ticketfrei.cfg.example index 094f789..0fa4f05 100644 --- a/ticketfrei.cfg.example +++ b/ticketfrei.cfg.example @@ -15,3 +15,11 @@ app_name = 'yourcity_ticketfrei' email = 'youremail@server.tld' password = 'yourpassword' server = 'yourmastodoninstance' + +[tuser] +consumer_key = "70982398n4cnc098rnnsc98nec" +consumer_secret = "09muvs098u08m9vsum098mu" +access_token_key = "u098umgfres09ug-f7n60cwhxm12" +access_token_secret = "8708mj9ßc298m343333333tex" + + diff --git a/trigger.py b/trigger.py index 78e6969..9f1f50a 100644 --- a/trigger.py +++ b/trigger.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +__encoding__ = "utf-8" class Trigger(object): @@ -21,10 +22,11 @@ class Trigger(object): :param string: A given string. Tweet or Toot, cleaned from html. :return: If the string passes the test """ + string = unicode.decode(string) for triggerword in self.goodlist: - if string.lower().find(triggerword): + if string.lower().find(triggerword) != -1: for triggerword in self.badlist: - if string.lower().find(triggerword): + if string.lower().find(triggerword) != -1: return False return True return False diff --git a/trigger.pyc b/trigger.pyc index 881b29b1e3319828ed8e0d7b7a18558d694a42e4..3a79646c9876915b941a04477599d15d34d68c4f 100644 GIT binary patch delta 416 zcmaJ+!AiqG5Ph?oZmhJXND+#9P^bh{^yo|LW_s?4|4S^ zcoaXwbNeISM9|sb*@bztZ|3dH+poE)b1pxNvmY-9O&@quB+q2cDtLjw=Gy}9#tTosg0yJGF>k!u==2?N52FeLPS47egt zyEwy8m_{tk@YupY7!mKimFQN`-_E2tmRA3j)}R#{_cfeqn{$OTb62F_VzLtb@Ns91 z6Wdr!BEJ)aEMW7Yxu#S3T%KpzD>1-!s6>k<-pAI2Xf3eJOoa`-j*|9Vp2b