small fixes, 280 limit, wait 60 seconds

This commit is contained in:
b3yond 2017-11-24 18:11:35 +01:00
parent c8e9d7fd7a
commit 1cab8dffb6
25 changed files with 26 additions and 26 deletions

1
local Submodule

@ -0,0 +1 @@
Subproject commit c8e9d7fd7ae0fe04921fdcf85e11fc9c0c324958

View file

@ -82,7 +82,6 @@ class RetootBot(object):
# boost mentions # boost mentions
retoots = [] retoots = []
try:
for notification in self.m.notifications(): for notification in self.m.notifications():
if (notification['type'] == 'mention' if (notification['type'] == 'mention'
and notification['status']['id'] not in self.seen_toots): and notification['status']['id'] not in self.seen_toots):
@ -91,8 +90,8 @@ class RetootBot(object):
notification['status']['content']) notification['status']['content'])
if not self.filter.is_ok(text_content): if not self.filter.is_ok(text_content):
continue continue
self.log('Boosting toot %d from %s: %s' % ( self.log('Boosting toot from %s: %s' % (
notification['status']['id'], #notification['status']['id'],
notification['status']['account']['acct'], notification['status']['account']['acct'],
notification['status']['content'])) notification['status']['content']))
self.m.status_reblog(notification['status']['id']) self.m.status_reblog(notification['status']['id'])
@ -100,10 +99,6 @@ class RetootBot(object):
notification['status']['account']['acct'], notification['status']['account']['acct'],
re.sub(r'@\S*', '', text_content))) re.sub(r'@\S*', '', text_content)))
# If the Mastodon instance returns interesting Errors, add them here: # If the Mastodon instance returns interesting Errors, add them here:
except mastodon.MastodonAPIError:
self.log("There was a Mastodon API Error, probably the API is not available.")
except mastodon.MastodonNetworkError:
self.log("There was a Mastodon Network Error, could not reach the server.")
# save state # save state
with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'w') as f: with os.fdopen(os.open('seen_toots.pickle.part', os.O_WRONLY | os.O_EXCL | os.O_CREAT), 'w') as f:

View file

@ -154,7 +154,7 @@ class RetweetBot(object):
return mentions return mentions
except twitter.TwitterError: except twitter.TwitterError:
self.log("Twitter API Error: Rate Limit Exceeded.") self.log("Twitter API Error: Rate Limit Exceeded.")
self.waitcounter += 60*15 self.waitcounter += 60*15 + 1
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
self.log("Twitter API Error: Bad Connection.") self.log("Twitter API Error: Bad Connection.")
self.waitcounter += 10 self.waitcounter += 10
@ -191,8 +191,8 @@ class RetweetBot(object):
:param post: String with the text to tweet. :param post: String with the text to tweet.
""" """
if len(post) > 140: if len(post) > 280:
post = post[:140 - 4] + u' ...' post = post[:280 - 4] + u' ...'
while 1: while 1:
try: try:
self.api.PostUpdate(status=post) self.api.PostUpdate(status=post)
@ -261,7 +261,9 @@ if __name__ == "__main__":
try: try:
while True: while True:
bot.flow() bot.flow()
sleep(10) sleep(60)
except KeyboardInterrupt:
print "Good bye! Remember to restart the bot."
except: except:
traceback.print_exc() traceback.print_exc()
print print

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -28,7 +28,9 @@ if __name__ == '__main__':
while True: while True:
statuses = mbot.retoot(statuses) statuses = mbot.retoot(statuses)
statuses = tbot.flow(statuses) statuses = tbot.flow(statuses)
time.sleep(10) time.sleep(60)
except KeyboardInterrupt:
print "Good bye. Remember to restart the bot!"
except: except:
traceback.print_exc() traceback.print_exc()
tbot.shutdown() tbot.shutdown()