feat: ignore bot msg

This commit is contained in:
Vaala Cat 2023-08-28 14:10:31 +08:00
parent 8f7bb8feba
commit 46cf57764c
4 changed files with 12 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
.env
run.sh
mcbot
*.sqlite
*.sqlite

View File

@ -97,3 +97,10 @@ func CronKick() {
}
})
}
func isBotMsg(msg chat.Message) bool {
if msg.Translate == "commands.message.display.outgoing" {
return true
}
return false
}

View File

@ -97,7 +97,7 @@ func onPlayerMsg(msg chat.Message, validated bool) error {
}
log.Printf("Player: %s", msg)
s := strings.Split(msg.String(), " ")
if len(s) > 1 {
if len(s) > 1 && !isBotMsg(msg) {
if s[0] != fmt.Sprintf("<%v>", conf.GetBotSettings().MCBotName) {
m := tgbotapi.NewMessage(conf.GetBotSettings().GroupID, fmt.Sprintf("%v", msg))
_, err := conf.Bot.Send(m)

View File

@ -60,7 +60,9 @@ func Run(sendFunc func(string)) {
logrus.Infof("id is %d", m.Chat.ID)
m := fmt.Sprintf("%v: %v", m.From.UserName, m.CommandArguments())
sendFunc(m)
logrus.WithError(err).Error("send message error")
if err != nil {
logrus.WithError(err).Error("send message error")
}
return
}
if m.Command() == "list" {