如何解决Telethon事件不会出错但也不会打印
因此,我尝试使用event.userUpdate,由于某种原因,它不起作用。 该脚本不会带来任何错误,但也不会打印任何状态更改。 有谁知道为什么吗?
from telethon.sync import TelegramClient
from telethon import events
from datetime import datetime
import time
### Client Side ###
target = ""
phone = "+"
api_id =
api_hash = ""
client = TelegramClient(phone,api_id,api_hash)
client.start()
if client.is_user_authorized():
print("Logging in to Telegram complete.")
else:
client.send_code_request(phone)
client.sign_in(phone,input('Enter the code: '))
time.sleep(2)
print(f"Started listening to {target}'s status...")
@client.on(events.UserUpdate())
async def handler(event):
event.user_id = target
if event.online:
print(f"{target} went Online at : {datetime.Now()}")
else:
print(f"{target} went Offline at : {datetime.Now()}")
if event.typing:
print(f"{target} was typing at : {datetime.Now()}")
client.run_until_disconnected()
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。