-
Notifications
You must be signed in to change notification settings - Fork 959
Simple Reply
Dharkael edited this page Feb 12, 2017
·
2 revisions
This is a very simple bot that just displays any gotten updates, then replies it to that chat.
package main
import (
"log"
"gopkg.in/telegram-bot-api.v4"
)
func main() {
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken")
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, err := bot.GetUpdatesChan(u)
for update := range updates {
if update.Message == nil {
continue
}
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text)
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text)
msg.ReplyToMessageID = update.Message.MessageID
bot.Send(msg)
}
}