@@ -90,6 +90,9 @@ type Context interface {
90
90
// In the case when no related data presented, returns an empty string.
91
91
Text () string
92
92
93
+ // ThreadID returns the current message thread ID.
94
+ ThreadID () int
95
+
93
96
// Entities returns the message entities, whether it's media caption's or the text's.
94
97
// In the case when no entities presented, returns a nil.
95
98
Entities () Entities
@@ -423,6 +426,15 @@ func (c *nativeContext) Args() []string {
423
426
return nil
424
427
}
425
428
429
+ func (c * nativeContext ) ThreadID () int {
430
+ switch {
431
+ case c .Message () != nil :
432
+ return c .Message ().ThreadID
433
+ default :
434
+ return 0
435
+ }
436
+ }
437
+
426
438
func (c * nativeContext ) Send (what interface {}, opts ... interface {}) error {
427
439
opts = c .inheritOpts (opts ... )
428
440
_ , err := c .b .Send (c .Recipient (), what , opts ... )
@@ -450,8 +462,8 @@ func (c *nativeContext) inheritOpts(opts ...interface{}) []interface{} {
450
462
}
451
463
452
464
switch {
453
- case ! ignoreThread && c .Message () != nil && c . Message (). ThreadID != 0 :
454
- opts = append (opts , & Topic {ThreadID : c .Message (). ThreadID })
465
+ case ! ignoreThread && c .ThreadID () != 0 :
466
+ opts = append (opts , & Topic {ThreadID : c .ThreadID () })
455
467
}
456
468
457
469
return opts
@@ -551,7 +563,7 @@ func (c *nativeContext) DeleteAfter(d time.Duration) *time.Timer {
551
563
}
552
564
553
565
func (c * nativeContext ) Notify (action ChatAction ) error {
554
- return c .b .Notify (c .Recipient (), action )
566
+ return c .b .Notify (c .Recipient (), action , c . ThreadID () )
555
567
}
556
568
557
569
func (c * nativeContext ) Ship (what ... interface {}) error {
0 commit comments