Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "log"
- tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
- )
- func main() {
- bot, err := tgbotapi.NewBotAPI("MY_SECRET_TOKEN")
- handleError("Couldn't access the bot API", err)
- bot.Debug = true
- fmt.Println("Authorized on account", bot.Self.UserName)
- upd := tgbotapi.NewUpdate(0)
- upd.Timeout = 60
- updates, err := bot.GetUpdatesChan(upd)
- handleError("Couldn't get an updates channel for the bot", err)
- for update := range updates {
- if update.Message != nil {
- msg := tgbotapi.NewMessage(update.Message.Chat.ID, "Hello!")
- bot.Send(msg)
- msg = tgbotapi.NewMessage(update.Message.Chat.ID, "Fuck you!")
- bot.Send(msg)
- }
- }
- }
- func handleError(message string, err error) {
- if err != nil {
- log.Fatalf("%s: %s", message, err)
- }
- }
Add Comment
Please, Sign In to add comment