From 570c656d0c078a0a5db1e0f4c93e4ef9052fbf22 Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 19 Aug 2021 17:26:05 +0300 Subject: [PATCH] context: add original update to the context --- bot.go | 2 +- context.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bot.go b/bot.go index 928525f..16d5db3 100644 --- a/bot.go +++ b/bot.go @@ -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, diff --git a/context.go b/context.go index 3a5610d..02d5f17 100644 --- a/context.go +++ b/context.go @@ -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: