Tishka17 / aiogram_dialog

GUI framework on top of aiogram
https://aiogram-dialog.readthedocs.io
Apache License 2.0
671 stars 103 forks source link

How to use old windows after restarting #347

Closed usaidinahui closed 9 months ago

usaidinahui commented 9 months ago

Hello there I use aiogram==2.25.2 aiogram-dialog==1.9.0

How to save context and use old messages after bot restarting?

File "/root/myproject/.venv/lib/python3.9/site-packages/aiogram_dialog/context/storage.py", line 27, in 
raise UnknownIntent(f"Context not found for intent id: {intent_id}")
aiogram_dialog.exceptions.UnknownIntent: Context not found for intent id: VbTTM5
Tishka17 commented 9 months ago

aiogram dialog actively uses FSM feature of aiogram, so you need to configure FSM Storage

usaidinahui commented 9 months ago

is any examples how to configure FSM in aiogram-dialog?

in my project I use it just like that

from aiogram import Bot, Dispatcher
from aiogram.contrib.fsm_storage.memory import MemoryStorage

bot = Bot(token=API_TOKEN, parse_mode=ParseMode.HTML)
storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)
usaidinahui commented 9 months ago

if anyone has the same question

apt install mongod
pip3 install pymongo
from aiogram import Bot, Dispatcher
from aiogram.contrib.fsm_storage.mongo import MongoStorage
from aiogram.types import ParseMode

storage = MongoStorage(
    host='localhost',
    port=27017,
    db='aiogram_fsm')
bot = Bot(token=API_TOKEN, parse_mode=ParseMode.HTML)
dp = Dispatcher(bot, storage=storage)
usaidinahui commented 9 months ago

PS. благодарю за отличный фреймворк, Тишка 🙏 и привет из УГАТУ выпуска `09