package main import ( "log" "os" mtrbus "github.com/tgckpg/golifehk/datasources/mtr/bus" tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5" ) func main() { bot, err := tgbotapi.NewBotAPI( os.Getenv( "TELEGRAM_API_TOKEN" ) ) if err != nil { log.Panic( err ) } bot.Debug = true log.Printf("Authorized on account %s", bot.Self.UserName) u := tgbotapi.NewUpdate(0) u.Timeout = 60 updates := bot.GetUpdatesChan(u) for update := range updates { if update.Message == nil { continue } log.Printf( "[%s] %s", update.Message.From.UserName, update.Message.Text ) result := mtrbus.Query( "zh", update.Message.Text ) msg := tgbotapi.NewMessage( update.Message.Chat.ID, result.Message() ) msg.ReplyToMessageID = update.Message.MessageID bot.Send( msg ) } }