V
V
Valde01832022-03-06 12:55:06
Python
Valde0183, 2022-03-06 12:55:06

Replay kick team?

Hello! I would like to ask experts how to implement the "kick" command on replay using the Vkbottle library. There is a team, but it kicks at the mention of the participant, but I would like it to be at the mention and replay.
I hope for a positive response, I just started learning the Vkbottle library recently.

If it’s not difficult, then I would be grateful if you show an example of creating permission to use the Kik command, otherwise you have to manually add IDs to permission, but I would like to give access to the command at the mention or replay. All the best!
The code:

@bp.on.chat_message(permission=([user_id, user_id]),text=['/кик', '/кик <member>'])
async def kick_handler(message: Message, member=None):
    try:
        if member is None:
            await message.answer('Не указан 1 параметр')
        else:
            try:
                member = re.findall(r'[0-9]+', member)[0]
                await bp.api.messages.remove_chat_user(message.chat_id, int(member))
                await message.answer(f"@id{member}(Пользователь) исключен")
            except VKAPIError as e:
                await message.answer(f" ⚠ Ошибка: {e}" )
    except:
        await message.answer('Укажите пользователя через @')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
defriz, 2022-03-07
@Valde0183

the message object should contain data about the replay, from there take the user ID that was replied to.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question