make toot->tweet format nicer

This commit is contained in:
b3yond 2017-07-11 23:50:55 +02:00
parent f881ab490e
commit d2910f8516
2 changed files with 6 additions and 2 deletions

View file

@ -59,7 +59,7 @@ class RetootBot(object):
if (notification['type'] == 'mention'
and notification['status']['id'] not in self.seen_toots):
self.seen_toots.add(notification['status']['id'])
text_content = re.sub('<[^>]*>', '',
text_content = re.sub(r'<[^>]*>', '',
notification['status']['content'])
if not self.filter.is_ok(text_content):
continue
@ -68,7 +68,9 @@ class RetootBot(object):
notification['status']['account']['acct'],
notification['status']['content']))
self.m.status_reblog(notification['status']['id'])
retoots.append(text_content)
retoots.append('%s: %s' % (
notification['status']['account']['acct'],
re.sub(r'@\S*', '', text_content)))
# 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

@ -138,6 +138,8 @@ class RetweetBot(object):
:param post: String with the text to tweet.
"""
if len(post) > 140:
post = post[:140 - 4] + u' ...'
while 1:
try:
self.api.PostUpdate(status=post)