Answer the question
In order to leave comments, you need to log in
I wrote a function and code for a personal mention of a conversation participant, but why doesn't it work?
I wrote code on VkLongPoll, and decided to make a function that will perform the task of mentioning a specific participant in the conversation, but when I write a command, the bot writes that the person was not found, here is the screen and the code:
name = get_name(from_id)
def get_name(from_id):
sender_info = getting_api.users.get(user_ids = from_id)[0]
full_name = sender_info.get('first_name') + ' ' + sender_info['last_name']
return full_name
def get_chat_member(id, group_id, user_name_search):
members = getting_api.messages.getConversationMembers(peer_id = 2000000000 + id, group_id = group_id)['profiles']
for i in range(len(members)):
if members[i]['first_name'] == user_name_search:
user_id = members[i]['id']
full_name = members[i]['first_name'] + ' ' + members[i]['last_name']
appeal = '*id' + str(user_id) + '(' + full_name + ')'
return appeal
elif mes[0:10] == '~kerinpush':
user_name_search = mes[11:]
chat_member = get_chat_member(id, 205491910, user_name_search)
if chat_member == None:
chatsender(id, "❌Такого человека нет в беседе❌")
else:
chatsender(id, chat_member + ', вас позвал' + name)<img src="https://habrastorage.org/webt/60/db/3a
Answer the question
In order to leave comments, you need to log in
First, it seems to me that you have lost the indentation. Check.
Second, when you slice mes[11:], what will be the first character?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question