context: add original update to the context

pull/447/head
Demian 3 years ago
parent cb12b170d3
commit 570c656d0c

@ -237,7 +237,7 @@ func (b *Bot) NewMarkup() *ReplyMarkup {
func (b *Bot) NewContext(upd Update) Context {
return &nativeContext{
b: b,
id: upd.ID,
update: upd,
message: upd.Message,
callback: upd.Callback,
query: upd.Query,

@ -13,12 +13,12 @@ type HandlerFunc func(Context) error
// Context wraps an update and represents the context of current event.
type Context interface {
// ID returns the update ID.
ID() int
// Bot returns the bot instance.
Bot() *Bot
// Update returns the original update.
Update() Update
// Message returns stored message if such presented.
Message() *Message
@ -149,7 +149,7 @@ type Context interface {
type nativeContext struct {
b *Bot
id int
update Update
message *Message
callback *Callback
query *Query
@ -165,14 +165,14 @@ type nativeContext struct {
store map[string]interface{}
}
func (c *nativeContext) ID() int {
return c.id
}
func (c *nativeContext) Bot() *Bot {
return c.b
}
func (c *nativeContext) Update() Update {
return c.update
}
func (c *nativeContext) Message() *Message {
switch {
case c.message != nil:

Loading…
Cancel
Save