feat: ignore bot msg
This commit is contained in:
parent
8f7bb8feba
commit
46cf57764c
@ -97,3 +97,10 @@ func CronKick() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isBotMsg(msg chat.Message) bool {
|
||||||
|
if msg.Translate == "commands.message.display.outgoing" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -97,7 +97,7 @@ func onPlayerMsg(msg chat.Message, validated bool) error {
|
|||||||
}
|
}
|
||||||
log.Printf("Player: %s", msg)
|
log.Printf("Player: %s", msg)
|
||||||
s := strings.Split(msg.String(), " ")
|
s := strings.Split(msg.String(), " ")
|
||||||
if len(s) > 1 {
|
if len(s) > 1 && !isBotMsg(msg) {
|
||||||
if s[0] != fmt.Sprintf("<%v>", conf.GetBotSettings().MCBotName) {
|
if s[0] != fmt.Sprintf("<%v>", conf.GetBotSettings().MCBotName) {
|
||||||
m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("%v", msg))
|
m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("%v", msg))
|
||||||
_, err := conf.Bot.Send(m)
|
_, err := conf.Bot.Send(m)
|
||||||
|
@ -60,7 +60,9 @@ func Run(sendFunc func(string)) {
|
|||||||
logrus.Infof("id is %d", m.Chat.ID)
|
logrus.Infof("id is %d", m.Chat.ID)
|
||||||
m := fmt.Sprintf("%v: %v", m.From.UserName, m.CommandArguments())
|
m := fmt.Sprintf("%v: %v", m.From.UserName, m.CommandArguments())
|
||||||
sendFunc(m)
|
sendFunc(m)
|
||||||
|
if err != nil {
|
||||||
logrus.WithError(err).Error("send message error")
|
logrus.WithError(err).Error("send message error")
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if m.Command() == "list" {
|
if m.Command() == "list" {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user