@amiruldaev

Проблема с созданием телеграм бота Python aiogram?

такая проблема, не могу создать телеграм бот, он должен принять от пользователя два значения, сложить их, и отправить то что получилось в чат
import asyncio
import time
import logging
from aiogram import Bot, Dispatcher, executor, types

TOKEN = "TOKEn"

logging.basicConfig(level=logging.INFO)

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

message_text = 0
message_text2 = 0

@dp.message_handler(commands=["start"])
async def start_handler(message: types.Message):
    user_id = message.from_user.id
    user_name = message.from_user.first_name
    user_full_name = message.from_user.full_name
    logging.info(f'{user_id} {user_full_name} {time.asctime()}')
    await message.reply(f"Привет, {user_full_name}!\nЧтобы посмотреть функции бота, нажмите на /help")

@dp.message_handler(commands=["help"])
async def help_handler(message: types.Message):
    await message.reply(f"/final - рассчитать необходимые баллы на final")

@dp.message_handler(commands=["final"])
async def final_handler(message: types.Message):
    await message.reply(f"Введите баллы за midterm:")

@dp.message_handler()
async def midterm_handler(message: types.Message):
    message_text = message.text
    # Add your logic to handle the midterm score and calculate necessary points for the final
    await message.reply(f"Введите баллы за endterm:")

@dp.message_handler()
async def endterm_handler(message: types.Message):
    message_text2 = message.text
    await message.reply(message_text+message_text2)

    # Add your logic to handle the endterm score and calculate necessary points for the final
    # Send the calculated points to the chat

if name == 'main':
    executor.start_polling(dp)
  • Вопрос задан
  • 50 просмотров
Пригласить эксперта
Ответы на вопрос 2
Vindicar
@Vindicar
RTFM!
Проблема с созданием телеграм бота Python aiogram?

Да, проблема.

Читай про finite state machine в aiogram.
Ответ написан
Комментировать
RimMirK
@RimMirK
Вроде человек. Вроде учусь. Вроде пайтону
пред последняя строчка кода c ошибкой. гугли if main
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы