twitter & masto sign limit

This commit is contained in:
b3yond 2018-04-15 11:42:34 +02:00
parent 758ff1db46
commit 7f8697947c
3 changed files with 9 additions and 6 deletions

View file

@ -56,7 +56,10 @@ class MastodonBot(Bot):
except Exception: except Exception:
logger.error('Error boosting: ' + report.id, exc_info=True) logger.error('Error boosting: ' + report.id, exc_info=True)
else: else:
text = report.text
if len(text) > 500:
text = text[:500 - 4] + u' ...'
try: try:
m.toot(report.text) m.toot(text)
except Exception: except Exception:
logger.error('Error tooting: ' + user.get_city() + ': ' + report.id, exc_info=True) logger.error('Error tooting: ' + user.get_city() + ': ' + report.id, exc_info=True)

View file

View file

@ -33,8 +33,7 @@ class TwitterBot(Bot):
if last_mention == 0: if last_mention == 0:
mentions = api.mentions_timeline() mentions = api.mentions_timeline()
else: else:
mentions = api.mentions_timeline( mentions = api.mentions_timeline(since_id=last_mention)
since_id=last_mention)
for status in mentions: for status in mentions:
text = re.sub( text = re.sub(
"(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)", "(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9-_]+)",
@ -62,9 +61,10 @@ class TwitterBot(Bot):
if report.source == self: if report.source == self:
api.retweet(report.id) api.retweet(report.id)
else: else:
# text = report.format() text = report.text
if len(report.text) > 280: if len(text) > 280:
text = report.text[:280 - 4] + u' ...' text = text[:280 - 4] + u' ...'
api.update_status(status=text)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
logger.error("Twitter API Error: Bad Connection", logger.error("Twitter API Error: Bad Connection",
exc_info=True) exc_info=True)