Reputation: 11
I am stuck in the middle with this code
from telethon import TelegramClient, sync
api_id = 99999
api_hash = 'secret_word'
client = TelegramClient('baracuda', api_id, api_hash)
@client.on(events.NewMessage(chats=('tester')))
async def normal_handler(event):
# print(event.message)
print(event.message.to_dict()['message'])
client.start()
client.run_until_disconnected()
I always have error
Traceback (most recent call last):
File "notification.py", line 9, in <module>
@client.on(events.NewMessage(chats=('chat_name')))
NameError: name 'events' is not defined
Please, help me to solve this issue
Upvotes: 1
Views: 1708
Reputation: 1715
Small mistake, You have to add:
from telethon import events
Hope this helps :)
Upvotes: 1