Telethon trouble: NameError: name 'events' is not defined
Telethon trouble: NameError: name 'events' is not defined
我被这段代码卡在了中间
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()
我总是出错
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
请帮我解决这个问题
小错误,您必须补充:
from telethon import events
希望这对您有所帮助:)
我被这段代码卡在了中间
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()
我总是出错
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
请帮我解决这个问题
小错误,您必须补充:
from telethon import events
希望这对您有所帮助:)