fsm-telebot icon indicating copy to clipboard operation
fsm-telebot copied to clipboard

fsm-telebot v2 alpha

Open vitaliy-ukiru opened this issue 11 months ago • 1 comments

The v2.x branch will release branch for v2

Main changes:

Storage

  • Added context arg
  • Memory storage moved to pkg/storage/memory
  • Use StorageKey for address user
  • Add Strategy for select mode of state
  • Deleted file storage

Context

  • Add context arg
  • Rename ContextMakerFunc to ContextFactory

Manager

  • Handlers routing logic was replaced to telebot-filter
  • Added state filters

States

  • Deleted Is, ContainsState functions. Use filters instead
  • Updated StateGroup's backend for more faster add, filter, get next and prev states (LinkedHashSet).

Other

Adapters

  • Adapter for old storage interface without context arg
  • Adapter for use FSM Context without context.Context
  • Package fsmopt for option-func build handers

Temporary changes

  • Deleted redis-storage submodule from main repo. But I'm think how it rollback with correct work.
  • Deleted test and examples
  • Deleted ugly middlewares adapters

StorageKey

Storage key stores: bot id, chat id, user id and thread id. Bot id is needed for support multibot with one storage. Thread id have zero value (0). In that case thread doen't count. Some fields must be same. It dependets from strategy

Strategy

Strategy for key - shows how need tell event's issuer. For your goals you can match:

  • Global user state (in every chats user have state state)
  • Chat mode (all users in chat have same state)
  • User in chat (every user in every chat have personal state, but theads don't count) - default
  • User in topic (user + chat + thread)
  • Chat topic (chat + thread)

Plans:

  • [ ] Delete Context.MustGet
  • [ ] Test converage
  • [ ] Smth...

vitaliy-ukiru avatar Mar 21 '24 07:03 vitaliy-ukiru