Answer the question
In order to leave comments, you need to log in
How to check for presence in a conversation?
Found the following function:
def check_kf(peer_id:int) -> list:
authorize.method("messages.getConversationMembers", {
"peer_id": peer_id
})["items"]
def add_v_besedy(sender,uid):
uid = reseived_message[10:19]
user_id = uid
if uid in check_kf(3):
write_message(sender,'text')
else:
write_message(sender,'as')
Answer the question
In order to leave comments, you need to log in
To start
in conversation with peer_id = 3
id=3
Then if uid in check_kf(3):
n't check through. check_kf
does not return anything, so it needs to be completeddef check_kf(peer_id:int) -> list:
return authorize.method("messages.getConversationMembers", {
"peer_id": peer_id
})["items"]
def add_v_besedy(sender,uid):
uid = reseived_message[10:19]
user_id = uid
users = check_kf(2000000003)
for user in users:
if user['member_id'] == user_id:
write_message(sender,'text')
return
write_message(sender,'as')
reseived_message[10:19]
clearly something wrong.
In fact, you simply do not return anything from the function, and this is an error, because you cannot check for the presence of a user in the list if this list does not exist
def check_kf(peer_id:int) -> list:
return authorize.method("messages.getConversationMembers", {
"peer_id": peer_id
})["items"]
1) Get a list of participants
2) Check if the required ID is in the list
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question