YoloSwagTeam / t2m

Twitter to Mastodon timeline forwarding tool
GNU General Public License v3.0
76 stars 15 forks source link

Still try to foward message longer thant the char limit #18

Closed zoski closed 6 years ago

zoski commented 6 years ago

TLDR

Message from twitter longer than the maximum toot size are always proceed event after they failed many times.

More in depth

Some messages from twitter like comments above a RT may be longer than 500 characters (the one bellow is 580 chars). For now, there is no verification of the length of tweet before t2m try to forward it to Mastodon. That lead to some messages to be blocked into t2m and never forwarded to Mastodon 'cause they are too long.

I edited the retweet.tmpl and removed the twit link to shorten the message but that's a temporary fix.

Trace

Traceback (most recent call last):
  File "./t2m", line 151, in forward
    response = mastodon.status_post(toot["text"], media_ids=medias)
  File "<decorator-gen-33>", line 2, in status_post
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 57, in wrapper
    return function(self, *args, **kwargs)
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 928, in status_post
    return self.__api_request('POST', '/api/v1/statuses', params)
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 1593, in __api_request
    raise MastodonAPIError("Mastodon API returned error: " + response['error'])
mastodon.Mastodon.MastodonAPIError: Mastodon API returned error: La validation a échoué : Text limite de caractères dépassée de 500 caractères
Traceback (most recent call last):
  File "./t2m", line 151, in forward
    response = mastodon.status_post(toot["text"], media_ids=medias)
  File "<decorator-gen-33>", line 2, in status_post
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 57, in wrapper
    return function(self, *args, **kwargs)
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 928, in status_post
    return self.__api_request('POST', '/api/v1/statuses', params)
  File "/home/bot/t2m/ve/local/lib/python3.5/site-packages/mastodon/Mastodon.py", line 1593, in __api_request
    raise MastodonAPIError("Mastodon API returned error: " + response['error'])
mastodon.Mastodon.MastodonAPIError: Mastodon API returned error: La validation a échoué : Text limite de caractères dépassée de 500 caractères
ERROR: could not forward the twitt [951018505633230848] 'Oufff, on rappelle pour nos amis faussaires et antidateurs que les ramettes de papier sont aussi datées (on en conserve au frais depuis 2012 au cas où à @dequaliter) https://t.co/4nvKHpIcei

RT « Ok, les fabricants d'imprimantes de bureau et la NSA se sont mis d'accord en 2005 pour ajouter un code indétectable à l'œil nu sur chaque page imprimée. Il donne les date et heure d'impression et le numéro de série de l'imprimante.

Plus d'infos ici : https://office-watch.com/2017/secret-printer-tracking-dots/ https://t.co/tJwURSFidr »

https://twitter.com/jjjlllnnn/status/950458552778444805
Tvax commented 6 years ago

Same problem, checking the toot length and adding the tweet to the db.json file without tooting it would be a good fix I guess.

Psycojoker commented 6 years ago

I think this was fixed by https://github.com/YoloSwagTeam/t2m/pull/20, could you confirm?

Tvax commented 6 years ago

Yeah I did a fix, but there's been a huge refacto afterwards which may have not implemented this fix

Psycojoker commented 6 years ago

Fix is still here after the refactoring (I made sure of porting everything) https://github.com/YoloSwagTeam/t2m/blob/master/t2m/__init__.py#L170-L184

Tvax commented 6 years ago

Ho yeah forgot about that, so I think we're all good because I couldn't reproduce the error

Psycojoker commented 6 years ago

Cool :)

Closing it for now, don't hesitate to re-open if you get the bug again (with the incriminated tweet if possible, like that we can diagnostic it)