diff --git a/button.go b/button.go index 6d7fb4e..0e3caa2 100644 --- a/button.go +++ b/button.go @@ -106,6 +106,9 @@ func (btn *Button) ToTelegramInline() apix.InlineKeyboardButton { // Return the key of the button to identify it by messages and callbacks. func (btn *Button) Key() string { + if btn == nil { + return "" + } if btn.Data != "" { return btn.Data } diff --git a/context.go b/context.go index 3796904..4d950f2 100644 --- a/context.go +++ b/context.go @@ -63,6 +63,21 @@ type Context struct { input *UpdateChan } +// Run commands as other user. Was implemented to +// make other user to leave the bot at first but +// maybe you will find another usage for this. +// Returns users context by specified session ID +// or nil if the user is not logged in. +func (c *Context) As(sid SessionId) *Context { + n, ok := c.Bot.contexts[sid] + if !ok { + return nil + } + return &Context{ + context: n, + } +} + func (c *Context) GetContext() *Context { return c }