From 698510358ae6e503af9b8b172ff2e215b104206a Mon Sep 17 00:00:00 2001 From: Nikita <59097534+nentenpizza@users.noreply.github.com> Date: Mon, 14 Oct 2024 18:52:59 +0300 Subject: [PATCH] context: make inheritOpts return new opts (#746) * context: make inheritOpts return new opts * context: add inheritOpts in SendAlbum --- context.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index 26e30f0a..22fc11c3 100644 --- a/context.go +++ b/context.go @@ -424,12 +424,12 @@ func (c *nativeContext) Args() []string { } func (c *nativeContext) Send(what interface{}, opts ...interface{}) error { - c.inheritOpts(opts) + opts = c.inheritOpts(opts) _, err := c.b.Send(c.Recipient(), what, opts...) return err } -func (c *nativeContext) inheritOpts(opts ...interface{}) { +func (c *nativeContext) inheritOpts(opts ...interface{}) []interface{} { var ( ignoreThread bool ) @@ -449,9 +449,13 @@ func (c *nativeContext) inheritOpts(opts ...interface{}) { case !ignoreThread && c.Message() != nil && c.Message().ThreadID != 0: opts = append(opts, Topic{ThreadID: c.Message().ThreadID}) } + + return opts } func (c *nativeContext) SendAlbum(a Album, opts ...interface{}) error { + opts = c.inheritOpts(opts) + _, err := c.b.SendAlbum(c.Recipient(), a, opts...) return err } @@ -461,7 +465,7 @@ func (c *nativeContext) Reply(what interface{}, opts ...interface{}) error { if msg == nil { return ErrBadContext } - c.inheritOpts(opts) + opts = c.inheritOpts(opts) _, err := c.b.Reply(msg, what, opts...) return err } @@ -481,7 +485,7 @@ func (c *nativeContext) ForwardTo(to Recipient, opts ...interface{}) error { } func (c *nativeContext) Edit(what interface{}, opts ...interface{}) error { - c.inheritOpts(opts) + opts = c.inheritOpts(opts) if c.u.InlineResult != nil { _, err := c.b.Edit(c.u.InlineResult, what, opts...) @@ -495,7 +499,7 @@ func (c *nativeContext) Edit(what interface{}, opts ...interface{}) error { } func (c *nativeContext) EditCaption(caption string, opts ...interface{}) error { - c.inheritOpts(opts) + opts = c.inheritOpts(opts) if c.u.InlineResult != nil { _, err := c.b.EditCaption(c.u.InlineResult, caption, opts...)