Reputation: 31
I take replier.py as base code from official Telethon examples.
I want to get message id each time I receive a message.
...
@events.register(events.NewMessage)
async def handler(event):
if not event.out:
print(f'received message_id = {event.message_id()}')
client = event.client
with client:
client.add_event_handler(handler)
client.run_until_disconnected()
>>> ... AttributeError: 'Message' object has no attribute 'message_id'
I've tried several variants with no success.
How to do it properly?
Upvotes: 2
Views: 7329
Reputation: 7141
It's an attribute, and you use the dot operator to access it:
@events.register(events.NewMessage)
async def handler(event):
message_id = event.id
print(message_id)
See also Telethon's FAQ on that topic.
Upvotes: 6