Z
Z
Zettt132019-01-22 12:10:44
Python
Zettt13, 2019-01-22 12:10:44

How to implement Kik user by group by id in a conversation?

You need to kick a user in a conversation using a group, for example:
/kick 333333
333333 is the user id.
The script is written on the vk_api library using LongPoll. Script example:

import vk_api # Библиотека VK
from datetime import datetime # Библиотека DateTime
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType # Библиотека VK LongPool

# Настройки
token = "токен" # Личный access_token сообщества (Желателен полный доступ)
group_id = "" # ID сообщества
server = "@id4" # Владелец кода
longpool_sleep = "0.5" # Задержка проверки сообщений, зависит от нагрузки на сервер (Рекомендуется значение от 0.1 до 10)

# VK LongPool
vk_session = vk_api.VkApi(token = token) # Обработка access_token
longpoll = VkBotLongPoll(vk_session, group_id) # Данные для работы в сообществе
vk = vk_session.get_api() # Работа с VK API

# Info
version = "release 7.0" # Версия бота
api_version = "5.92" # Версия VK API
system = "LongPoll" # LongPoll или CallBack
language = "Python 3.7.2" # Язык и версия языка

# Time
servertime = str(datetime.strftime(datetime.now(), "%H:%M")) # Время сервера

# Сообщения
for event in longpoll.listen():

    if event.type == VkBotEventType.MESSAGE_NEW and event.obj.text.lower() == "test" or event.obj.text.lower() == "тест":
        vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Tested!")
        vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Отправьте команду help для получения списка комманд бота")
 
    if event.type == VkBotEventType.MESSAGE_NEW and event.obj.text.lower() == "help" or event.obj.text.lower() == "помощь":
        vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Список комманд:\n\ntest или тест\nТестовая проверка\n\nhelp или помощь\nСписок комманд\n\ntime или время\nВремя сервера\n\nserver или сервер\nКто запустил сервер\n\ninfo или инфо\nИнформация о боте")

    if event.type == VkBotEventType.MESSAGE_NEW and event.obj.text.lower() == "time" or event.obj.text.lower() == "время":
        vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Время сервера: " + servertime)

    if event.type == VkBotEventType.MESSAGE_NEW and event.obj.text.lower() == "server" or event.obj.text.lower() == "сервер":
    	vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Сервер запустил: " + server)

    if event.type == VkBotEventType.MESSAGE_NEW and event.obj.text.lower() == "info" or event.obj.text.lower() == "инфо":
    	vk.messages.send(peer_id = event.obj.peer_id, random_id = 0, message = "Версия: " + version + "\nVK API: " + api_version + "\nСистема: " + system + "\nЯзык: " + language + "\n\nРазработчики:\nRaven INC (2018 - 2019)\[email protected] @valerongf17\[email protected] @i.abrams\[email protected] @id468143118")

time.sleep(longpool_sleep)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Kirill Minovsky, 2019-01-22
@Zettt13

in your bible it will be like this
And if you are talking about the implementation itself, then when you receive a message, you break it up by a space. If the first part is /kick, then the second part will contain the id of the user being kicked

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question