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

yoo i tried literally all night and my brain is bout to exploade!! ill try some more for sure but help :0 #44

Open
davad00 opened this issue Mar 1, 2024 · 1 comment

Comments

@davad00
Copy link

davad00 commented Mar 1, 2024

if you try to fetch a message that is not there (been deleted or "0" for example) it gives error..
"
Telegram says: [400 ME
SSAGE_EMPTY] - The message sent is empty or contains invalid characters (caused
by "messages.SendMessage")
"
i couldnt find a way around it or a way to filter those messages :(

i tried looking but i failed :((((
https://docs.pyrogram.org/api/methods/send_message#send-message
https://docs.pyrogram.org/telegram/types/message-empty
https://docs.pyrogram.org/api/errors/bad-request#

thanks in advance for the help! :)

@muhammetkbs
Copy link

muhammetkbs commented Mar 2, 2024

Empty message exception is not handled at main.py, You can use my code example to handle this exception.

First paste this line to line 3 in main.py

from pyrogram.errors import UserAlreadyParticipant, InviteHashExpired, UsernameNotOccupied, MessageEmpty

Then scroll down to line 113 and change the line by using my code example. Be careful about indentation and your problem will be solved.

try:
	handle_private(message,chatid,msgid)
except MessageEmpty as e:
	bot.send_message(message.chat.id,f"**Caught a message empty exception** : __{e}__", reply_to_message_id=message.id)
	continue
except pyrogram.errors.exceptions.TelegramError as e:
	bot.send_message(message.chat.id,f"**Caught a TelegramErrorException** : __{e}__", reply_to_message_id=message.id)
	continue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants