I have a code and found out that:
@client.on(events.NewMessage(from_users=channels))
async def main(event):
print(event.message)
and
@client.on(events.NewMessage(chats=channels))
async def main(event):
print(event.message)
work exactly the same. What is the difference in these args then?
It has no difference so I'm interested how it works
The source code for Telethon is on Github and you can inspect it there. This might be what you are after:
Per: telethon/events/newmessage.py
from_users (`entity`, optional): Unlike `chats`, this parameter filters the *senders* of the message. That is, only messages *sent by these users* will be handled. Use `chats` if you want private messages with this/these users. `from_users` lets you filter by messages sent by *one or more* users across the desired chats (doesn't need a list).