From cf5edf4042f36e3929a880c526321c875e56e6fb Mon Sep 17 00:00:00 2001 From: Demian Date: Thu, 8 Oct 2020 22:46:26 +0300 Subject: [PATCH] context: implement the opposite to Forward --- context.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index 2af0a55..7d67dd1 100644 --- a/context.go +++ b/context.go @@ -40,11 +40,11 @@ type Context interface { // Migration returns both migration from and to chat IDs. Migration() (int64, int64) - // Sender returns a current recipient, depending on the context type. + // Sender returns the current recipient, depending on the context type. // Returns nil if user is not presented. Sender() Recipient - // Text returns a current text, depending on the context type. + // Text returns the current text, depending on the context type. // If the context contains payment, returns its payload. // In the case when no related data presented, returns an empty string. Text() string @@ -65,15 +65,19 @@ type Context interface { // See Reply from bot.go. Reply(what interface{}, opts ...interface{}) error - // Forward forwards a given message to the current recipient. + // Forward forwards the given message to the current recipient. // See Forward from bot.go. Forward(msg Editable, opts ...interface{}) error - // Edit edits a current message. + // ForwardTo forwards the current message to the given recipient. + // See Forward from bot.go + ForwardTo(to Recipient, opts ...interface{}) error + + // Edit edits the current message. // See Edit from bot.go. Edit(what interface{}, opts ...interface{}) error - // EditCaption edits a caption of the current message. + // EditCaption edits the caption of the current message. // See EditCaption from bot.go. EditCaption(caption string, opts ...interface{}) error @@ -234,6 +238,11 @@ func (c *nativeContext) Forward(msg Editable, opts ...interface{}) error { return err } +func (c *nativeContext) ForwardTo(to Recipient, opts ...interface{}) error { + _, err := c.b.Forward(to, c.Message(), opts...) + return err +} + func (c *nativeContext) Edit(what interface{}, opts ...interface{}) error { msg := c.Message() if msg == nil {