bipinkrish / Save-Restricted-Bot

A Telegram Bot, Which can send you restricted content by it's post link
180 stars 370 forks source link

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 4 months ago

davad00 commented 4 months ago

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 commented 4 months ago

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