From d2910f851634fe456d91d7fdb6c844bc8f9bd8ed Mon Sep 17 00:00:00 2001 From: b3yond Date: Tue, 11 Jul 2017 23:50:55 +0200 Subject: [PATCH] make toot->tweet format nicer --- retootbot.py | 6 ++++-- retweetbot.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/retootbot.py b/retootbot.py index 879a948..63e16da 100644 --- a/retootbot.py +++ b/retootbot.py @@ -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: diff --git a/retweetbot.py b/retweetbot.py index 348c4d3..0586216 100644 --- a/retweetbot.py +++ b/retweetbot.py @@ -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)