You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
706 B
Go
36 lines
706 B
Go
2 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
|
||
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
||
|
)
|
||
|
|
||
|
func main() {
|
||
|
bot, err := tgbotapi.NewBotAPI("5913395413:AAEcaXZPbsldBW2kFNKy3NwUf5LAyetj_0Y")
|
||
|
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 {
|
||
|
// If we got a message
|
||
|
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)
|
||
|
}
|
||
|
}
|
||
|
}
|