R
R
Ramazan Ramazanov2021-07-15 15:23:50
Python
Ramazan Ramazanov, 2021-07-15 15:23:50

I am writing a bot on aiogram, no errors come out. The ban command does not work, although everything is correct. wat tu doo?

import logging
import config
from aiogram import Dispatcher, types, Bot, executor
from filters import AdminFilter

logging.basicConfig(level=logging.INFO)

bot = Bot(token=config.TOKEN)
dp = Dispatcher(bot)

#код, где я писал комманду БАН
dp.filters_factory.bind(AdminFilter)
@dp.message_handler(is_admin=True, commands=["ban"], commands_prefix='!/')
async def cmd_ban(message:types.Message):
    if not message.reply_to_message:
        await message.reply("Ответчай на сообщение, дурачок")
        return

    await message.bot.delete_message(chat_id=config.GROUP_ID, message_id=message.message_id)
    await message.bot.kick_chat_member(chat_id=config.GROUP_ID, user_id=message.reply_to_message.from_user.id)

    await message.reply_to_message.reply("Этот чел был забанен.\n Админ даун, кста")




@dp.message_handler(content_types=["new_chat_members"])
async def joined(message:types.Message):
    await message.answer("Привет, рады, что ты присоединился")
    await message.delete()


@dp.message_handler()
async def filter_message(message:types.Message):
    if "матюк" in message.text:
        await message.delete()



if __name__ == '__main__':
    executor.start_polling(dp, skip_updates=False)


I did not consider it necessary to write the filter code. Everything is right there))

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question