fixing stuff

This commit is contained in:
b3yond 2017-06-18 00:35:34 +02:00
parent 18a9b706b0
commit f0f5d91813
7 changed files with 27 additions and 6 deletions

View file

@ -22,6 +22,14 @@ Install dependencies
$ pip3 install Mastodon.py pytoml pickle $ pip3 install Mastodon.py pytoml pickle
$ pip install python-twitter pytoml requests $ 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 ## ideas

View file

@ -6,5 +6,4 @@ jude
schwuchtel schwuchtel
fag fag
faggot faggot
arbeitsplätze

View file

@ -45,7 +45,7 @@ class RetootBot(object):
self.config['muser']['password'] self.config['muser']['password']
) )
def retoot(self, toots=[]): def retoot(self, toots=()):
# toot external provided messages # toot external provided messages
for toot in toots: for toot in toots:
self.m.toot(toot) self.m.toot(toot)

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
__encoding__ = "utf-8"
import twitter import twitter
import requests import requests
@ -105,6 +106,9 @@ class RetweetBot(object):
try: try:
mentions = self.api.GetMentions(since_id=self.last_mention) mentions = self.api.GetMentions(since_id=self.last_mention)
return mentions return mentions
except twitter.TwitterError:
print("[ERROR] Rate Limit exceeded, trying again once a minute")
sleep(60)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
print("[ERROR] Bad Connection.") print("[ERROR] Bad Connection.")
sleep(10) sleep(10)
@ -118,7 +122,7 @@ class RetweetBot(object):
""" """
while 1: while 1:
try: try:
self.api.PostRetweet(status.id) print self.api.PostRetweet(status.id)
return self.format_mastodon(status) return self.format_mastodon(status)
# Hopefully we got rid of this error. If not, try to uncomment these lines. # Hopefully we got rid of this error. If not, try to uncomment these lines.
# except twitter.error.TwitterError: # except twitter.error.TwitterError:
@ -181,7 +185,7 @@ if __name__ == "__main__":
# create an Api object # create an Api object
bot = RetweetBot() bot = RetweetBot()
while True: while True:
sleep(1) sleep(10)
bot.flow() bot.flow()
#except: #except:
# bot.shutdown() # bot.shutdown()

View file

@ -15,3 +15,11 @@ app_name = 'yourcity_ticketfrei'
email = 'youremail@server.tld' email = 'youremail@server.tld'
password = 'yourpassword' password = 'yourpassword'
server = 'yourmastodoninstance' server = 'yourmastodoninstance'
[tuser]
consumer_key = "70982398n4cnc098rnnsc98nec"
consumer_secret = "09muvs098u08m9vsum098mu"
access_token_key = "u098umgfres09ug-f7n60cwhxm12"
access_token_secret = "8708mj9ßc298m343333333tex"

View file

@ -1,4 +1,5 @@
#!/usr/bin/env python #!/usr/bin/env python
__encoding__ = "utf-8"
class Trigger(object): class Trigger(object):
@ -21,10 +22,11 @@ class Trigger(object):
:param string: A given string. Tweet or Toot, cleaned from html. :param string: A given string. Tweet or Toot, cleaned from html.
:return: If the string passes the test :return: If the string passes the test
""" """
string = unicode.decode(string)
for triggerword in self.goodlist: for triggerword in self.goodlist:
if string.lower().find(triggerword): if string.lower().find(triggerword) != -1:
for triggerword in self.badlist: for triggerword in self.badlist:
if string.lower().find(triggerword): if string.lower().find(triggerword) != -1:
return False return False
return True return True
return False return False

Binary file not shown.