if event.object.text == "онлайн":
members = vk.method("messages.getConversationMembers",
{
"peer_id": event.object.peer_id,
}
)['profiles']
useronline = members['online']
if useronline == 1:
user = vk.method("users.get",
{
"peer_id": event.object.peer_id,
}
)['response']
userid = user['id']
full_name = user['first_name'] + " " + user['last_name']
online = " " + f'[id{userid}|{full_name}]' + "\n"
vk.method("messages.send",
{
"chat_id": event.object.peer_id - 2000000000,
"message": " Сейчас в сети: " + f'\n{online}',
"random_id": random.randint(1, 2147483647)
})
def get_members(peer_id: int):
return vk.method("messages.getConversationMembers", {
"peer_id": peer_id
})
if event.object.text.lower() == "онлайн":
members = [
f"[id{i['id']}|{i['first_name']} {i['last_name']}]"
for i in get_members(event.object.peer_id)["profiles"]
if i["online"] == 1
]
vk.method("messages.send", {
"peer_id": event.obj.peer_id,
"random_id": 0,
"message": "Сейчас в сети: {}".format(
"\n".join(members)
)
})