Answer the question
In order to leave comments, you need to log in
How to select two users from a conversation?
Hello, I need to get two random IDs from a conversation using the messages.getConversationMembers method and turn them into usernames.
I have already done this before, but in that case there was an outdated method and one user, here is the script:
peplist = session_api.messages.getChatUsers(chat_id=chat_id)
ranpep = random.choice(peplist)
user_get = session_api.users.get(user_ids = ranpep)
user_get = user_get[0]
first_name = user_get['first_name']
last_name = user_get['last_name']
full_name = first_name+" "+last_name
Answer the question
In order to leave comments, you need to log in
Since python 3.6: Documentation
ranpeps = random.choices(peplist, 2)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question