Reputation: 1
I want to check a user's online status every 1 minute. I used the following code but after a while I received the following error.
from telethon import TelegramClient, events, sync
import time
api_id = my_api_id
api_hash = my_api_hash
username = my_username
client = TelegramClient(username, api_id, api_hash)
client.start()
while True:
account = client.get_entity(target_username)
print(account.status.to_dict())
time.sleep(60)
Error after working for a while:
A wait of 56063 seconds is required (caused by ResolveUsernameRequest)
Upvotes: 0
Views: 1181
Reputation: 7141
The closest you can get is events.UserUpdate
, for things like "user is typing" and so on.
@client.on(events.UserUpdate)
async def handler(event):
... # use event
You can also use the user ID instead of the username which has lower flood limits. However, Telegram can still suspect of API misuse and issue any flood limits it wants.
Upvotes: 1