context: add message Entities function

pull/572/head
Demian 2 years ago
parent 4c17ca7dc7
commit ad84cbde5a

@ -70,6 +70,10 @@ type Context interface {
// In the case when no related data presented, returns an empty string.
Text() string
// Entities returns the message entities, whether it's media caption's or the text's.
// In the case when no entities presented, returns a nil.
Entities() Entities
// Data returns the current data, depending on the context type.
// If the context contains command, returns its arguments string.
// If the context contains payment, returns its payload.
@ -297,6 +301,17 @@ func (c *nativeContext) Text() string {
return m.Text
}
func (c *nativeContext) Entities() Entities {
m := c.Message()
if m == nil {
return nil
}
if len(m.CaptionEntities) > 0 {
return m.CaptionEntities
}
return m.Entities
}
func (c *nativeContext) Data() string {
switch {
case c.u.Message != nil:

Loading…
Cancel
Save