Connect with Telegram bot API
bot := telegram.NewBot("<token>")
bot.SetCommand("[/]<cmd>", <commandAction>)
bot.AllMessage(<action>)
bot.StartWithWebhook("<url>", <port>)
bot.Start()
bot.SendTextMessage(<chat-id>, <message>, <0|message-id>)
func main(){
// Create bot
bot := telegram.NewBot("<token>")
//Configure command
bot.SetCommand("start", start)
//All Messages
bot.AllMessage(catchAll)
//Use webhook
bot.StartWithWebhook("http://mywebhook.com", 8080)
}
func start(update *models.Update){
bot.SendTextMessage(update.GetChatID(), "Hello, the bot now is running!", 0)
}
func catchAll(update *models.Update) {
fmt.Println("new message received")
}