Skip to content

Commit

Permalink
context: update edit functions
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Aug 31, 2021
1 parent 888979b commit f457be5
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,26 +364,31 @@ func (c *nativeContext) Edit(what interface{}, opts ...interface{}) error {
}

func (c *nativeContext) EditCaption(caption string, opts ...interface{}) error {
clb := c.callback
if clb == nil || clb.Message == nil {
return ErrBadContext
if c.inlineResult != nil {
_, err := c.b.EditCaption(c.inlineResult, caption, opts...)
return err
}
_, err := c.b.EditCaption(clb.Message, caption, opts...)
return err
if c.callback != nil {
_, err := c.b.Edit(c.callback, caption, opts...)
return err
}
return ErrBadContext
}

func (c *nativeContext) EditOrSend(what interface{}, opts ...interface{}) error {
if c.callback != nil {
return c.Edit(what, opts...)
err := c.Edit(what, opts...)
if err == ErrBadContext {
return c.Send(what, opts...)
}
return c.Send(what, opts...)
return err
}

func (c *nativeContext) EditOrReply(what interface{}, opts ...interface{}) error {
if c.callback != nil {
return c.Edit(what, opts...)
err := c.Edit(what, opts...)
if err == ErrBadContext {
return c.Reply(what, opts...)
}
return c.Reply(what, opts...)
return err
}

func (c *nativeContext) Delete() error {
Expand Down

0 comments on commit f457be5

Please sign in to comment.