Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle "no links found" properly #433

Open
PROger4ever opened this issue Sep 24, 2024 · 0 comments
Open

Handle "no links found" properly #433

PROger4ever opened this issue Sep 24, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@PROger4ever
Copy link

PROger4ever commented Sep 24, 2024

Problem

When no links found in incoming message, ytdlbot tries to send an empty message:

[2024-09-24 01:01:01 ytdl_bot.py:589 I] start ['Respect💯 Greatest Save🦸\u200d♂️ #shorts #short #status #humanity #viral\nhttps://youtube.com/shorts/1K1pMdQzV1M?si=uze3jaacXuKeWDNG']
[2024-09-24 01:01:01 database.py:113 I] Setting metrics: bad_request
[2024-09-24 01:01:01 _client.py:1038 I] HTTP Request: POST https://www.youtube.com/youtubei/v1/search?key=GOOGLE_API_KEY_HIDDEN "HTTP/1.1 200 OK"
[2024-09-24 01:01:01 dispatcher.py:328 E] Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyrogram/dispatcher.py", line 317, in handler_worker
    await self.loop.run_in_executor(
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/ytdlbot/ytdlbot/ytdl_bot.py", line 118, in wrapper
    return func(client, message)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/ytdlbot/ytdlbot/ytdl_bot.py", line 596, in download_handler
    message.reply_text(text, quote=True, disable_web_page_preview=True)
  File "/usr/local/lib/python3.11/site-packages/pyrogram/sync.py", line 78, in async_to_sync_wrap
    return asyncio.run_coroutine_threadsafe(coroutine, main_loop).result()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 456, in result
    return self.__get_result()
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/concurrent/futures/_base.py", line 401, in __get_result
    raise self._exception
  File "/usr/local/lib/python3.11/site-packages/pyrogram/types/messages_and_media/message.py", line 1377, in reply_text
    return await self._client.send_message(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyrogram/methods/messages/send_message.py", line 168, in send_message
    r = await self.invoke(
        ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyrogram/methods/advanced/invoke.py", line 94, in invoke
    r = await session.invoke(
        ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyrogram/session/session.py", line 406, in invoke
    return await self.send(query, timeout=timeout)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyrogram/session/session.py", line 374, in send
    RPCError.raise_it(result, type(data))
  File "/usr/local/lib/python3.11/site-packages/pyrogram/errors/rpc_error.py", line 91, in raise_it
    raise getattr(
pyrogram.errors.exceptions.bad_request_400.MessageEmpty: Telegram says: [400 MESSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused by "messages.SendMessage")

So user doesn't understand what's going on :)

@BennyThink BennyThink added the bug Something isn't working label Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants