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,28 +82,23 @@ class RetootBot(object):
# boost mentions
retoots = []
try:
for notification in self.m.notifications():
if (notification['type'] == 'mention'
and notification['status']['id'] not in self.seen_toots):
self.seen_toots.add(notification['status']['id'])
text_content = re.sub(r'<[^>]*>', '',
notification['status']['content'])
if not self.filter.is_ok(text_content):
continue
self.log('Boosting toot %d from %s: %s' % (
notification['status']['id'],
notification['status']['account']['acct'],
notification['status']['content']))
self.m.status_reblog(notification['status']['id'])
retoots.append('%s: %s' % (
notification['status']['account']['acct'],
re.sub(r'@\S*', '', text_content)))
for notification in self.m.notifications():
if (notification['type'] == 'mention'
and notification['status']['id'] not in self.seen_toots):
self.seen_toots.add(notification['status']['id'])
text_content = re.sub(r'<[^>]*>', '',
notification['status']['content'])
if not self.filter.is_ok(text_content):
continue
self.log('Boosting toot from %s: %s' % (
#notification['status']['id'],
notification['status']['account']['acct'],
notification['status']['content']))
self.m.status_reblog(notification['status']['id'])
retoots.append('%s: %s' % (
notification['status']['account']['acct'],
re.sub(r'@\S*', '', text_content)))
# 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
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
except twitter.TwitterError:
self.log("Twitter API Error: Rate Limit Exceeded.")
self.waitcounter += 60*15
self.waitcounter += 60*15 + 1
except requests.exceptions.ConnectionError:
self.log("Twitter API Error: Bad Connection.")
self.waitcounter += 10
@ -191,8 +191,8 @@ class RetweetBot(object):
:param post: String with the text to tweet.
"""
if len(post) > 140:
post = post[:140 - 4] + u' ...'
if len(post) > 280:
post = post[:280 - 4] + u' ...'
while 1:
try:
self.api.PostUpdate(status=post)
@ -261,7 +261,9 @@ if __name__ == "__main__":
try:
while True:
bot.flow()
sleep(10)
sleep(60)
except KeyboardInterrupt:
print "Good bye! Remember to restart the bot."
except:
traceback.print_exc()
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:
statuses = mbot.retoot(statuses)
statuses = tbot.flow(statuses)
time.sleep(10)
time.sleep(60)
except KeyboardInterrupt:
print "Good bye. Remember to restart the bot!"
except:
traceback.print_exc()
tbot.shutdown()