yuletide / nitterbot

A mastodon bot to replace twitter links with Nitter links to view without ads or tracking
https://botsin.space/@nitterbot
7 stars 3 forks source link

Crash - Unprocessable Entity #15

Open yuletide opened 1 year ago

yuletide commented 1 year ago
2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] ===== found mention in reply to yuletide id 109391862882784405 =====

2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] {'id': 109637543306988869, 'created_at': datetime.datetime(2023, 1, 5, 16, 29, 5, tzinfo=tzlocal()), 'in_reply_to_id': 109637082336261225, 'in_reply_to_account_id': 96, 'sensitive': False, 'spoiler_text': '', 'visibility': 'public', 'language': 'en', 'uri': 'https://mastodon.social/users/yuletide/statuses/109637543253605488', 'url': 'https://mastodon.social/@yuletide/109637543253605488', 'replies_count': 0, 'reblogs_count': 0, 'favourites_count': 0, 'edited_at': None, 'favourited': False, 'reblogged': False, 'muted': False, 'bookmarked': False, 'content': '<p><span class="h-card"><a href="https://mastodon.cloud/@anildash" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>anildash</span></a></span> <span class="h-card"><a href="https://botsin.space/@nitterbot" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>nitterbot</span></a></span> please convert</p>', 'filtered': [], 'reblog': None, 'account': {'id': 109391862882784405, 'username': 'yuletide', 'acct': 'yuletide@mastodon.social', 'display_name': 'alex yuletide', 'locked': False, 'bot': False, 'discoverable': True, 'group': False, 'created_at': datetime.datetime(2022, 6, 21, 0, 0, tzinfo=tzlocal()), 'note': '<p>Spatial solutions arch &amp; web dev, social justice, civic tech, heavy metal. Available for work! \u2029Proud parent to <span class="h-card"><a href="https://botsin.space/@nitterbot" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>nitterbot</span></a></span>\u2028\u2029\u2029Past: Mapbox Solutions Architect &amp; Tech Lead @ Community Team, <span class="h-card"><a href="https://mastodon.social/@recursecenter" class="u-url mention" rel="nofollow noopener noreferrer" target="_blank">@<span>recursecenter</span></a></span> fellow, founder of civic tech startup now part of @granicus, @codeforamerica fellow, @esri\u2029\u2028\u2029<a href="https://mastodon.social/tags/vegetarian" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>vegetarian</span></a> <a href="https://mastodon.social/tags/zen" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>zen</span></a> <a href="https://mastodon.social/tags/metal" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>metal</span></a> <a href="https://mastodon.social/tags/bassmusic" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>bassmusic</span></a> <a href="https://mastodon.social/tags/dj" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>dj</span></a> <a href="https://mastodon.social/tags/maps" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>maps</span></a> <a href="https://mastodon.social/tags/photography" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>photography</span></a> <a href="https://mastodon.social/tags/webdev" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>webdev</span></a> <a href="https://mastodon.social/tags/politics" class="mention hashtag" rel="nofollow noopener noreferrer" target="_blank">#<span>politics</span></a></p>', 'url': 'https://mastodon.social/@yuletide', 'avatar': 'https://files.botsin.space/cache/accounts/avatars/109/391/862/882/784/405/original/0efc492b3538e902.png', 'avatar_static': 'https://files.botsin.space/cache/accounts/avatars/109/391/862/882/784/405/original/0efc492b3538e902.png', 'header': 'https://files.botsin.space/cache/accounts/headers/109/391/862/882/784/405/original/1f2a8c1cc92143b4.png', 'header_static': 'https://files.botsin.space/cache/accounts/headers/109/391/862/882/784/405/original/1f2a8c1cc92143b4.png', 'followers_count': 150, 'following_count': 88, 'statuses_count': 213, 'last_status_at': datetime.datetime(2023, 1, 5, 0, 0), 'emojis': [], 'fields': [{'name': 'Birdsite', 'value': '<a href="HTTPS://twitter.com/yuletide" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible"></span><span class="">HTTPS://twitter.com/yuletide</span><span class="invisible"></span></a>', 'verified_at': None}, {'name': 'LinkedSite', 'value': '<a href="https://linkedin.com/in/alexyule" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="">linkedin.com/in/alexyule</span><span class="invisible"></span></a>', 'verified_at': None}]}, 'media_attachments': [], 'mentions': [{'id': 96, 'username': 'anildash', 'url': 'https://mastodon.cloud/@anildash', 'acct': 'anildash@mastodon.cloud'}, {'id': 109543657746642932, 'username': 'nitterbot', 'url': 'https://botsin.space/@nitterbot', 'acct': 'nitterbot'}], 'tags': [], 'emojis': [], 'card': None, 'poll': None}

2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] filtered status @anildash @nitterbot please convert

2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] checking parentnd, checking parent

2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] Fetching parent

2023-01-05T16:29:08.540 app[d5f49ab5] sjc [info] Fetching parent

2023-01-05T16:29:09.336 app[d5f49ab5] sjc [info] {'id': 109637082336261225, 'created_at': datetime.datetime(2023, 1, 5, 14, 31, 51, tzinfo=tzlocal()), 'in_reply_to_id': None, 'in_reply_to_account_id': None, 'sensitive': False, 'spoiler_text': '', 'visibility': 'public', 'language': 'en', 'uri': 'https://mastodon.cloud/users/anildash/statuses/109637082251702595', 'url': 'https://mastodon.cloud/@anildash/109637082251702595', 'replies_count': 3, 'reblogs_count': 4, 'favourites_count': 0, 'edited_at': None, 'favourited': False, 'reblogged': False, 'muted': False, 'bookmarked': False, 'content': '<p>This thread is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. <a href="https://twitter.com/modernserf/status/1610702219149557762" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="ellipsis">twitter.com/modernserf/status/</span><span class="invisible">1610702219149557762</span></a></p>', 'filtered': [], 'reblog': None, 'account': {'id': 96, 'username': 'anildash', 'acct': 'anildash@mastodon.cloud', 'display_name': 'Anil', 'locked': False, 'bot': False, 'discoverable': True, 'group': False, 'created_at': datetime.datetime(2017, 4, 5, 0, 0, tzinfo=tzlocal()), 'note': '<p>big fan of being a big fan of things. amateur real-time historian. you can email me at a@anildash.com or SMS/signal at +1 646 541 5843.</p>', 'url': 'https://mastodon.cloud/@anildash', 'avatar': 'https://files.botsin.space/cache/accounts/avatars/000/000/096/original/f8c040687402cc81.png', 'avatar_static': 'https://files.botsin.space/cache/accounts/avatars/000/000/096/original/f8c040687402cc81.png', 'header': 'https://files.botsin.space/cache/accounts/headers/000/000/096/original/02be71256d3b0811.jpeg', 'header_static': 'https://files.botsin.space/cache/accounts/headers/000/000/096/original/02be71256d3b0811.jpeg', 'followers_count': 25630, 'following_count': 715, 'statuses_count': 1591, 'last_status_at': datetime.datetime(2023, 1, 5, 0, 0), 'emojis': [], 'fields': [{'name': 'Website', 'value': '<a href="https://anildash.com/" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="">anildash.com/</span><span class="invisible"></span></a>', 'verified_at': '2023-01-05T14:32:08.734+00:00'}]}, 'media_attachments': [], 'mentions': [], 'tags': [], 'emojis': [], 'card': {'url': 'https://twitter.com/modernserf/status/1610702219149557762', 'title': 'Justin Falcone 🐀 on Twitter', 'description': '“A few years ago I worked at a startup that had "innovated" their healthcare plan such that we had no dental or mental health coverage but we could get partially reimbursed if we filed them as expense reports”', 'type': 'link', 'author_name': '', 'author_url': '', 'provider_name': 'Twitter', 'provider_url': '', 'html': '', 'width': 0, 'height': 0, 'image': None, 'embed_url': '', 'blurhash': None}, 'poll': None}

2023-01-05T16:29:09.336 app[d5f49ab5] sjc [info] {'id': 109637082336261225, 'created_at': datetime.datetime(2023, 1, 5, 14, 31, 51, tzinfo=tzlocal()), 'in_reply_to_id': None, 'in_reply_to_account_id': None, 'sensitive': False, 'spoiler_text': '', 'visibility': 'public', 'language': 'en', 'uri': 'https://mastodon.cloud/users/anildash/statuses/109637082251702595', 'url': 'https://mastodon.cloud/@anildash/109637082251702595', 'replies_count': 3, 'reblogs_count': 4, 'favourites_count': 0, 'edited_at': None, 'favourited': False, 'reblogged': False, 'muted': False, 'bookmarked': False, 'content': '<p>This thread is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. <a href="https://twitter.com/modernserf/status/1610702219149557762" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="ellipsis">twitter.com/modernserf/status/</span><span class="invisible">1610702219149557762</span></a></p>', 'filtered': [], 'reblog': None, 'account': {'id': 96, 'username': 'anildash', 'acct': 'anildash@mastodon.cloud', 'display_name': 'Anil', 'locked': False, 'bot': False, 'discoverable': True, 'group': False, 'created_at': datetime.datetime(2017, 4, 5, 0, 0, tzinfo=tzlocal()), 'note': '<p>big fan of being a big fan of things. amateur real-time historian. you can email me at a@anildash.com or SMS/signal at +1 646 541 5843.</p>', 'url': 'https://mastodon.cloud/@anildash', 'avatar': 'https://files.botsin.space/cache/accounts/avatars/000/000/096/original/f8c040687402cc81.png', 'avatar_static': 'https://files.botsin.space/cache/accounts/avatars/000/000/096/original/f8c040687402cc81.png', 'header': 'https://files.botsin.space/cache/accounts/headers/000/000/096/original/02be71256d3b0811.jpeg', 'header_static': 'https://files.botsin.space/cache/accounts/headers/000/000/096/original/02be71256d3b0811.jpeg', 'followers_count': 25630, 'following_count': 715, 'statuses_count': 1591, 'last_status_at': datetime.datetime(2023, 1, 5, 0, 0), 'emojis': [], 'fields': [{'name': 'Website', 'value': '<a href="https://anildash.com/" rel="nofollow noopener noreferrer" target="_blank"><span class="invisible">https://</span><span class="">anildash.com/</span><span class="invisible"></span></a>', 'verified_at': '2023-01-05T14:32:08.734+00:00'}]}, 'media_attachments': [], 'mentions': [], 'tags': [], 'emojis': [], 'card': {'url': 'https://twitter.com/modernserf/status/1610702219149557762', 'title': 'Justin Falcone 🐀 on Twitter', 'description': '“A few years ago I worked at a startup that had "innovated" their healthcare plan such that we had no dental or mental health coverage but we could get partially reimbursed if we filed them as expense reports”', 'type': 'link', 'author_name': '', 'author_url': '', 'provider_name': 'Twitter', 'provider_url': '', 'html': '', 'width': 0, 'height': 0, 'image': None, 'embed_url': '', 'blurhash': None}, 'poll': None}

2023-01-05T16:29:09.336 app[d5f49ab5] sjc [info] filtered status This thread is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. https://twitter.com/modernserf/status/1610702219149557762

2023-01-05T16:29:09.336 app[d5f49ab5] sjc [info] *birdsite detected, replacing*

2023-01-05T16:29:09.336 app[d5f49ab5] sjc [info] This thread is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. https://unofficialbird.com/modernserf/status/1610702219149557762

2023-01-05T16:29:09.337 app[d5f49ab5] sjc [info] parent had twitter link!is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. https://unofficialbird.com/modernserf/status/1610702219149557762

2023-01-05T16:29:09.337 app[d5f49ab5] sjc [info] Your nitterified status

2023-01-05T16:29:09.337 app[d5f49ab5] sjc [info] Your nitterified status s ready: This thread is from a larger-context conversation about why some tech workers choose to work for giants like Google; Justin details their experience in systemic failures with healthcare and benefits at a startup. Since I was CEO of that startup, it’s worth sharing the insights I got into how these systems fail, in hopes that other workers (and well-intentioned managers) can avoid replicating these problems and sparing people pain. https://unofficialbird.com/modernserf/status/1610702219149557762

2023-01-05T16:29:09.578 app[d5f49ab5] sjc [info] Traceback (most recent call last):

2023-01-05T16:29:09.578 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main

2023-01-05T16:29:09.579 app[d5f49ab5] sjc [info] return _run_code(code, main_globals, None,

2023-01-05T16:29:09.579 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] exec(code, run_globals)

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] File "/app/nitterbot/__main__.py", line 32, in <module>

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] main()

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] File "/app/nitterbot/__main__.py", line 20, in main

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] mastodon.stream_user(listener)

2023-01-05T16:29:09.580 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/decorator.py", line 232, in fun

2023-01-05T16:29:09.581 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/

2023-01-05T16:29:09.581 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/ astodon/utility.py", line 47, in wrapper

2023-01-05T16:29:09.582 app[d5f49ab5] sjc [info] return function(self, *args, **kwargs)

2023-01-05T16:29:09.582 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/streaming_endpoints.py", line 20, in stream_user

2023-01-05T16:29:09.582 app[d5f49ab5] sjc [info] return self.__stream('/api/v1/streaming/user', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec)

2023-01-05T16:29:09.582 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/internals.py", line 544, in __stream

2023-01-05T16:29:09.583 app[d5f49ab5] sjc [info] listener.handle_stream(r)

2023-01-05T16:29:09.583 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/streaming.py", line 125, in handle_stream

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] self._dispatch(event)

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/streaming.py", line 216, in _dispatch

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] handler(payload)

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] File "/app/nitterbot/notifylistener.py", line 15, in on_notification

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] process_mention(notification, self.api)

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] File "/app/nitterbot/bot.py", line 119, in process_mention

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] api.status_reply(

2023-01-05T16:29:09.584 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/decorator.py", line 232, in fun

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] return caller(func, *(extras + args), **kw)

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/utility.py", line 47, in wrapper

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-pack

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-pack ges/mastodon/statuses.py", line 363, in status_reply

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] return self.status_post(**keyword_args)

2023-01-05T16:29:09.585 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/decorator.py", line 232, in fun

2023-01-05T16:29:09.586 app[d5f49ab5] sjc [info] return caller(func, *(extras + args), **kw)

2023-01-05T16:29:09.586 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/utility.py", line 47, in wrapper

2023-01-05T16:29:09.586 app[d5f49ab5] sjc [info] return function(self, *args, **kwargs)

2023-01-05T16:29:09.586 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/statuses.py", line 253, in status_post

2023-01-05T16:29:09.587 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/si

2023-01-05T16:29:09.587 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/si e-packages/mastodon/statuses.py", line 187, in __status_internal

2023-01-05T16:29:09.587 app[d5f49ab5] sjc [info] return self.__api_request('POST', '/api/v1/statuses', params, headers=headers, use_json=use_json)

2023-01-05T16:29:09.587 app[d5f49ab5] sjc [info] File "/usr/local/lib/python3.9/site-packages/mastodon/internals.py", line 299, in __api_request

2023-01-05T16:29:09.587 app[d5f49ab5] sjc [info] raise ex_type('Mastodon API returned error', response_object.status_code, response_object.reason, error_msg)

2023-01-05T16:29:09.588 app[d5f49ab5] sjc [info] mastodon.errors.MastodonAPIError: ('Mastodon API returned error', 422, 'Unprocessable Entity', 'Validation failed: Text character limit of 500 exceeded')

2023-01-05T16:29:09.652 app[d5f49ab5] sjc [info] Starting clean up.
yuletide commented 1 year ago

This is due to a status over 500 characters, how do we trim this? Split in two? In above example the original status is 493 characters, so it seems by adding our @reply tags we hit the limit, and the API wrapper doesn't seem smart about detecting that.