D
D
Danil Samusev2019-05-08 09:09:42
In contact with
Danil Samusev, 2019-05-08 09:09:42

How to make it so that the report in the VK bot is sent to all admins in the bot?

There is no way I can make the bot send all the admins about the report. Tell me the code please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Just1n, 2019-05-08
@danilka238

If the report was written in a conversation

import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType

vk_session = vk_api.VkApi(token='токен бота')
vk = vk_session.get_api()

longpoll = VkBotLongPoll(vk_session, id группы-бота)

while True:
    for event in longpoll.listen():
        if event.type == VkBotEventType.MESSAGE_NEW:
            if event.object.peer_id != event.object.from_id:
                if event.object.text.lower() == 'репорт':
                    vk.messages.send(peer_id=event.object.peer_id, message='Введите свой репорт', random_id=0)
                    for event in longpoll.listen():
                        if event.type == VkBotEventType.MESSAGE_NEW:
                            if event.object.peer_id != event.object.from_id:
                                vk.messages.send(peer_id=event.object.peer_id, message='Спасибо за репорт! Я отправлю его нашим админам', random_id=0)
                                vk.messages.send(user_id=id админа, message='Репорт от пользователя:\n' + str(event.object.text.lower()), random_id=0)

If there are several admins, duplicate the last line several times and in each place user_id write the admin id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question