@bot.on.chat_message(text = ["/kick <args>", "/kick"])
async def kick(message: Message, args: Optional[str] = None):
cursor.execute(f"SELECT * FROM user WHERE vk_id = {message.from_id} AND chat_id = {message.peer_id}")
info_user = cursor.fetchone()
access_roles = ["Модератор", "Главный Модератор", "Администратор"]
if info_user[4] not in access_roles:
return
if message.reply_message == None:
user = args.split(' ')[0]
args = args.replace(user, "")
reason = args[1:]
if reason == "":
reason = "Не указана."
if "[id" in user:
user = int(user.split("|")[0].replace("[id", ""))
if message.reply_message != None:
user = message.reply_message.from_id
reason = args
if reason == "":
reason = "Не указана."
await bot.api.messages.remove_chat_user(chat_id=message.peer_id - 2000000000, user_id=user)
await message.answer(f"[id{user}|Пользователь] был исключён из конференции.\n \nИсключил: [id{message.from_id}|{info_user[4]}]\n Причина: {reason}")
cursor.execute(f"DELETE FROM user WHERE vk_id = {user} AND chat_id = {message.peer_id}")
connection.commit()