Reputation: 47
i wanna filter the events.newMessage
to fire only when messages are coming from private chats.
but i don't want to put all chat ids in chats list argument of the event
do you have any ideas ?
@client.on(events.NewMessage)
async def my_event_handler(event):
if 'hello' in event.raw_text:
await client.delete_messages(await event.get_chat(), event.id)
in the example above think i a want to delete all messages coming from private chats ( everyone of them )
Upvotes: 2
Views: 2091
Reputation: 1237
NewMessage
events implement the ChatGetter class so you can use the following :
event.is_private
→ User
event.is_group
→ Chat and Channel (megagroup flag set)
event.is_channel
→ Channel
Also for a more of a complete answer
any private = is_private
any group = is_group
any channel = is_channel
only small groups = is_group and not is_channel
only mega groups = is_group and is_channel
only broadcast channels = not is_group and is_channel
Upvotes: 7