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
$ 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

View file

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

View file

@ -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)

View file

@ -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()

View file

@ -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"

View file

@ -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

Binary file not shown.