twitter & masto sign limit

master
b3yond 2018-04-15 11:42:34 +02:00
parent 1c13be1ef4
commit bc742f7dcc
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)