Home>
Please tell me, the bot starts up, but the states do not work, you click to view the profile, but nothing happens, what can I fix in the code?
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import FSMContext
import config
import random
from on_startup_notify import on_startup_notify
from memorystate import Test
from aiogram import types, Bot, executor, Dispatcher
bot= Bot (token= config.BOT_TOKEN, parse_mode= types.ParseMode.HTML)
dp= Dispatcher (bot)
storage= MemoryStorage ()
async def on_startup (dispatcher):
await on_startup_notify (dispatcher)
@ dp.message_handler (commands= ['start'])
async def startpg (message: types.Message, state: FSMContext):
startmenu= types.ReplyKeyboardMarkup (resize_keyboard= True, row_width= 2)
markup1= types.KeyboardButton ("View profile")
startmenu.add (markup1)
await bot.send_message (chat_id= message.chat.id, text= 'Welcome! \ nOur bot will introduce you to girls from your city! Click to view the profile!', reply_markup= startmenu)
await state.set_data (Test.N1)
@ dp.message_handler (text= ['View profile'], state= Test.N1)
async def osnova (message: types.Message, state: FSMContext):
await bot.send_message (message.chat.id, 'Enter your name:')
answer= message.text
await state.update_data (answer1= answer)
await Test.N2.set ()
I tried to install it in different ways, it does not help, but how to check if the state is being set? what to fix in this code? everything seems to be ready to go
Иван Сидоров2021-02-28 17:35:12Related questions
- How to connect time in a telegram bot in Python?
- python : How to check for a running timer? pytelegrambotapi
- python : Sending scheduled telebot messages
- python : Sending a message telegram bot
- Python Parser not working (debian server)
- Hanging a thread in python
- python : Discord.py How to hang up cooldown on push reaction?
- python : While loop. How to write a program using it on assignment?
- python : Filtering text and links
firstly, you set the states in different ways, secondly -check if it is set at all, thirdly -your state is set when you start command, and not when you press a button
finally2021-02-28 17:35:12