R
R
Roman2021-08-20 00:32:52
Python
Roman, 2021-08-20 00:32:52

Why is there no error in the console, but the message (123) is not sent (aiogram)?

import logging

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

from aiogram.types import ReplyKeyboardRemove, \
    ReplyKeyboardMarkup, KeyboardButton, \
    InlineKeyboardMarkup, InlineKeyboardButton

test = False

button_hi = KeyboardButton('Привет! ', test=True)
button_hii = KeyboardButton('123')

greet_kb = ReplyKeyboardMarkup()
greet_kb.add(button_hi, button_hii)

bot = Bot(token = "туто мой токен, но я убрал")
dp = Dispatcher(bot)

logging.basicConfig(level = logging.INFO)


@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
    await bot.send_message(message.from_user.id, test, reply_markup=greet_kb)
    

if test == True:
    async def prdfg(message: types.Message):
        await bot.send_message(message.from_user.id,'123')



if __name__ == "__main__":
    executor.start_polling(dp, skip_updates=True)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-08-20
@Filian

test = False
Below
if test == True:
async def prdfg(message: types.Message):
You won't have prdfg declared because test is still False when this line is executed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question