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