package main import ( "context" "fmt" "os" "github.com/mymmrac/telego" tu "github.com/mymmrac/telego/telegoutil" ) func main() { ctx := context.Background() botToken := os.Getenv("TOKEN") // Create Bot // Note: Please keep in mind that default logger may expose sensitive information, use in development only bot, err := telego.NewBot(botToken, telego.WithDefaultDebugLogger()) if err != nil { fmt.Println(err) os.Exit(1) } // Call method getMe botUser, _ := bot.GetMe(ctx) fmt.Printf("Bot User: %+v\n", botUser) updates, _ := bot.UpdatesViaLongPolling(ctx, nil) for update := range updates { if update.Message != nil { // Retrieve chat ID chatID := update.Message.Chat.ID // Call method sendMessage (https://core.telegram.org/bots/api#sendmessage). // Send a message to sender with the same text (echo bot). sentMessage, _ := bot.SendMessage(ctx, tu.Message( tu.ID(chatID), update.Message.Text, ), ) fmt.Printf("Sent Message: %v\n", sentMessage) } } }