You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
printercu edited this page Nov 18, 2017
·
1 revision
Sometimes you may want to have several session objects. For example, in group chat one session object tracks data which is about the chat and other session tracks user-specific data:
protected# Default `#session` tracks user-specific data.defsession_key"#{bot.username}:#{from['id']}"iffromend# It defines one more session object.# This one will hold same data for all updates in group chat.defchat_session@_chat_session ||= self.class.build_session(chat && "#{bot.username}:#{chat['id']}")end# Note that you need to save it yourself, like it done in Session module:defprocess_action(*)superensurechat_session.commitif@_chat_sessionend