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
Example with session.Manager + tgb.Router.MessageReaction()
router:=tgb.NewRouter().
Use(sessionManager). // *session.Manager[T]Message(func(ctx context.Context, msg*tgb.MessageUpdate) error {
// this works// TODO...returnnil
}).
MessageReaction(func(ctx context.Context, reaction*tgb.MessageReactionUpdate) error {
// this doesn't work // as session.Manager.Wrap() returns an error "can't get key from update" // TODO...returnnil
})
session.Manager.Wrap() returns an error because of its default session.KeyFuncChat() which calls tg.Update.Msg() method (not directly)
// Msg returns message from whever possible.// It returns nil if message is not found.func (update*Update) Msg() *Message {
switch {
caseupdate==nil:
returnnilcaseupdate.Message!=nil:
returnupdate.Messagecaseupdate.EditedMessage!=nil:
returnupdate.EditedMessagecaseupdate.ChannelPost!=nil:
returnupdate.ChannelPostcaseupdate.EditedChannelPost!=nil:
returnupdate.EditedChannelPostcaseupdate.CallbackQuery!=nil&&update.CallbackQuery.Message!=nil&&update.CallbackQuery.Message.Message!=nil:
returnupdate.CallbackQuery.Message.Messagecaseupdate.BusinessMessage!=nil:
returnupdate.BusinessMessagecaseupdate.EditedBusinessMessage!=nil:
returnupdate.EditedBusinessMessagedefault:
returnnil
}
}
this method do not cover update.MessageReaction, MessageReactionCount (and probably some other types which can return Chat field needed for session.KeyFuncChat())
So, @mr-linch, is this a bug, or this is intentional? This also can be fixed by passing custom KeyFunc which handles all cases...
What do you think?
BTW, thanks for the great package!
The text was updated successfully, but these errors were encountered:
Example with session.Manager + tgb.Router.MessageReaction()
session.Manager.Wrap()
returns an error because of its defaultsession.KeyFuncChat()
which callstg.Update.Msg()
method (not directly)this method do not cover
update.MessageReaction
,MessageReactionCount
(and probably some other types which can returnChat
field needed forsession.KeyFuncChat()
)So, @mr-linch, is this a bug, or this is intentional? This also can be fixed by passing custom KeyFunc which handles all cases...
What do you think?
BTW, thanks for the great package!
The text was updated successfully, but these errors were encountered: