Sam-Max/rcmltb

Bot errors on channel

Zriel88 opened this issue · 2 comments

Using any command on channels, I get this error:

2023-10-18 14:18:08,912 - pyrogram.dispatcher - ERROR - 'NoneType' object has no attribute 'id'
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/dispatcher.py", line 226, in handler_worker
    if await handler.check(self.client, parsed_update):
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/handlers/handler.py", line 35, in check
    return await self.filters(client, update)
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/filters.py", line 79, in __call__
    y = await self.other(client, update)
  File "/usr/local/lib/python3.10/dist-packages/pyrogram/filters.py", line 97, in __call__
    x = await self.base(client, update)
  File "/usr/src/app/bot/helper/telegram_helper/filters.py", line 17, in custom_user_filter
    uid= update.from_user.id
AttributeError: 'NoneType' object has no attribute 'id'

Maybe aI need to fill in the "ALLOWED_CHATS" ??

pousay commented

hello,
channel has no from_user data.
use this instead

update.chat.id

this is the chat id of the message
for example you want to reply to that message in the same channel that message has been sent
you can use :

chat_id = update.chat.id
await app.send_message(chat_id,"hello")

Fixed now.