S
S
samatv2021-08-09 18:57:04
Python
samatv, 2021-08-09 18:57:04

Why doesn't the bot give back the phrase?

The bot responds to the start and help, you write a text to it, this text does not give back.

from aiogram import Bot, types
from aiogram.dispatcher import Dispatcher
from aiogram.utils import executor


TOKEN = "1800205287:AAGg4o6TLnpx7iFyyB-wX0rJUYciRUNAmOw"
admin_id = 1800205287


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

@dp.message_handler(commands=['start'])
async def process_start_command(message: types.Message):
    await message.reply("Привет!\nНапиши мне что-нибудь!")

@dp.message_handler(commands=['help'])
async def process_help_command(message: types.Message):
    await message.reply("Напиши мне что-нибудь, и я отправлю этот текст тебе в ответ!")


@dp.message_handler()
async def echo_message(msg: types.Message):
    await bot.send_message(msg.from_user.id, msg.text)   

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)
S
soremix, 2021-08-09
@samatv

Errors from the console and highlighting from the IDE? The bot variable is not defined.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question