Answer the question
In order to leave comments, you need to log in
How to get username via reply?
I noted " --- here--- " where the problem is in the code
. When the user writes !rep, the name of the sender is indicated, and not to whom
it was sent. to whom this request was sent.
from aiogram.types import User
import config
import logging
from aiogram import Dispatcher, Bot, types, executor
logging.basicConfig(level=logging.INFO)
bot = Bot(token=config.TOKEN)
dp = Dispatcher(bot)
from filters import IsAdminFilter
dp.filters_factory.bind(IsAdminFilter)
@dp.message_handler(is_admin=True, commands='ban', commands_prefix='!/' )
async def ban(message: types.Message):
if not message.reply_to_message:
await message.reply('Для бана пользователя, эта команда должна быть ответом на его сообщение')
return
await message.bot.delete_message(config.GROUP_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('Пользователь забанен')
@dp.message_handler(commands='rep', commands_prefix='!/' )
async def rep(message: types.Message):
if not message.reply_to_message:
await message.reply('Для респекта нужно ответить сообщением пользователю\nкоторому хотите отправить респекст')
return
await message.reply(f'Вы респектанули, {message.from_user.first_name}') <b>- --Здесь---</b>
@dp.message_handler()
async def delte(message: types.Message):
if 'https://' in message.text:
await message.delete()
if __name__ == '__main__':
executor.start_polling(dp, skip_updates=True)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question