Only reply to mentions

This commit is contained in:
斟酌 鵬兄 2022-09-15 20:25:29 +08:00
parent 89770c0864
commit 67e3ec1500

11
main.go
View File

@ -3,6 +3,7 @@ package main
import (
"log"
"os"
"strings"
mtrbus "github.com/tgckpg/golifehk/datasources/mtr/bus"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
)
@ -29,11 +30,13 @@ func main() {
log.Printf( "[%s] %s", update.Message.From.UserName, update.Message.Text )
result := mtrbus.Query( "zh", update.Message.Text )
if strings.Contains( update.Message.Text, "@golifehkbot" ){
result := mtrbus.Query( "zh", strings.Replace( update.Message.Text, "@golifehkbot", "", -1 ) )
msg := tgbotapi.NewMessage( update.Message.Chat.ID, result.Message() )
msg.ReplyToMessageID = update.Message.MessageID
msg := tgbotapi.NewMessage( update.Message.Chat.ID, result.Message() )
msg.ReplyToMessageID = update.Message.MessageID
bot.Send( msg )
bot.Send( msg )
}
}
}