Skip to content

Commit

Permalink
context: make inheritOpts return new opts (#746)
Browse files Browse the repository at this point in the history
* context: make inheritOpts return new opts

* context: add inheritOpts in SendAlbum
  • Loading branch information
nentenpizza authored Oct 14, 2024
1 parent e337578 commit 6985103
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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...)
Expand All @@ -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...)
Expand Down

0 comments on commit 6985103

Please sign in to comment.