Answer the question
In order to leave comments, you need to log in
Trying to get user status (online/offline) by bot message(aiogram + pyrogram)?
I'm trying to do the following:
@dp.message_handler(regexp="View user")
async def checkuser(message: types.Message):
await message.answer("Enter username")
id = message.text
with app:
g = app. get_users("hankipoiii").status
print(g)
if g== "online":
timewentonline = datetime.datetime.now()
goodtime = datetime.datetime.today()
while g == "online":
timewentoff = datetime. datetime.now()
alltime = round((timewentoff - timewentonline).total_seconds())
if alltime >= 60:
await message.answer(
f"User with username {id} was online at {goodtime}\nTime spent online: {alltime / 60} minutes")
if alltime >= 3600:
await message.answer(
f"User with username {id} was online at {goodtime}\nTime spent online: {alltime / 3600} hours")
else:
await message.answer(
f"User with username {id} was online at {goodtime}\nTime spent online: {alltime} seconds")
writes the following:
AttributeError: 'coroutine' object has no attribute 'status'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question