mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix telegram filterPlaintextMessages
This commit is contained in:
parent
eba6706b92
commit
e3a894eb7e
|
@ -2,6 +2,7 @@ package telegramnotifier
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -55,18 +56,20 @@ func (n *Notifier) Notify(obj interface{}, args ...interface{}) {
|
||||||
func filterPlaintextMessages(args []interface{}) (texts []string, pureArgs []interface{}) {
|
func filterPlaintextMessages(args []interface{}) (texts []string, pureArgs []interface{}) {
|
||||||
var firstObjectOffset = -1
|
var firstObjectOffset = -1
|
||||||
for idx, arg := range args {
|
for idx, arg := range args {
|
||||||
switch a := arg.(type) {
|
rt := reflect.TypeOf(arg)
|
||||||
|
if rt.Kind() == reflect.Ptr {
|
||||||
|
switch a := arg.(type) {
|
||||||
|
case types.PlainText:
|
||||||
|
texts = append(texts, a.PlainText())
|
||||||
|
if firstObjectOffset == -1 {
|
||||||
|
firstObjectOffset = idx
|
||||||
|
}
|
||||||
|
|
||||||
case types.PlainText:
|
case types.Stringer:
|
||||||
texts = append(texts, a.PlainText())
|
texts = append(texts, a.String())
|
||||||
if firstObjectOffset == -1 {
|
if firstObjectOffset == -1 {
|
||||||
firstObjectOffset = idx
|
firstObjectOffset = idx
|
||||||
}
|
}
|
||||||
|
|
||||||
case types.Stringer:
|
|
||||||
texts = append(texts, a.String())
|
|
||||||
if firstObjectOffset == -1 {
|
|
||||||
firstObjectOffset = idx
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user