Answer the question
In order to leave comments, you need to log in
How to display usernames from the list?
Hello, I'm making a kind of "table" where information about the current administrators and the creator is displayed, but there was a problem when I wanted to display a name for each ID in this table. How to do it?
Script that displays the table:
if msg == "!админы":
data1 = session_api.messages.getConversationMembers(peer_id=event.peer_id)
admin = [x["member_id"] for x in data1["items"] if x.get("is_admin", False)]
data2 = session_api.messages.getConversationMembers(peer_id=event.peer_id)
owner = [x["member_id"] for x in data2["items"] if x.get("is_owner", False)]
owner_info = session_api.users.get(user_ids = owner)
admin_info = session_api.users.get(user_ids = admin)
owner_id = owner_info[0]["id"]
full_name = owner_info[0]['first_name'] + ' ' + owner_info[0]['last_name']
send_message(peer_id=event.peer_id,message=" Создатель беседы:\n● @id" + str(owner_id) + "(" + str(full_name) + ")\n Администрация:\n" + str('\n'.join('● @id{}(Пользователь)' for _ in range(len(admin))).format(*admin)))
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