M
M
Max2021-10-20 21:10:31
Python
Max, 2021-10-20 21:10:31

How to assign multiple values ​​to a variable for telegram feedback bot?

There is a feedback bot via telegram, if the interlocutor writes, then his message is sent to the admin and you can answer through the replay. There is a ban list, but for some reason it works with only one id, I tried it with a list, converted the list to int, all in vain. If anyone has experience with this, I'd be grateful.
The code

from aiogram import Bot, Dispatcher, executor, types
from aiogram import *
from aiogram.types import *

TOKEN = "2085132748:AAHTBPLybX-3Sa9Iedha5PiMmXnKNllk504"
admin_id = 957778963
#Тут хотелось бы перечислить список id в бан листе
a1 = 1390587152

boty = Bot(token=TOKEN)
dp = Dispatcher(boty)


@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
    if message['from'].id == admin_id:
        await message.answer(f"Hi, admin")
    elif message['from'].id == a1:
        await message.answer(f"You BAN !")

    else:
        await message.answer(f"Hi, {message['from'].first_name}!")


@dp.message_handler()
async def process_start_command(message: types.Message):
    if message['from'].id == a1:
        await message.answer(f"You BAN !")
    elif message.reply_to_message == None:
        if '/start' not in message.text:
            await boty.forward_message(admin_id, message.from_user.id, message.message_id)

    else:
        if message['from'].id == admin_id:
            if message.reply_to_message.forward_from.id:
                await boty.send_message(message.reply_to_message.forward_from.id, message.text)
        else:
             None


@dp.message_handler(content_types=['photo'])
async def handle_docs_photo(message):
    await boty.forward_message(admin_id, message.from_user.id, message.message_id)


@dp.message_handler(content_types=['document'])
async def handle_docs_photo(message):
    await boty.forward_message(admin_id, message.from_user.id, message.message_id)


if __name__ == '__main__':
    print("starting")
executor.start_polling(dp)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WolfInChains, 2021-10-20
@ronvarvar2

To check if an id is in the list, you need to use in, not==

a1 = [1234567, 8901234]

if from_id in a1:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question