|
|
@ -18,35 +18,32 @@ package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"github.com/Syfaro/telegram-bot-api" |
|
|
|
"github.com/zhulik/telegram-bot-api" |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func main() { |
|
|
|
func main() { |
|
|
|
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") |
|
|
|
bot, err := tgbotapi.NewBotAPI("MyAwesomeBotToken") |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
log.Panic(err) |
|
|
|
log.Panic(err) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bot.Debug = true |
|
|
|
bot.Debug = true |
|
|
|
|
|
|
|
|
|
|
|
log.Printf("Authorized on account %s", bot.Self.UserName) |
|
|
|
log.Printf("Authorized on account %s", bot.Self.UserName) |
|
|
|
|
|
|
|
|
|
|
|
u := tgbotapi.NewUpdate(0) |
|
|
|
u := tgbotapi.NewUpdate(0) |
|
|
|
u.Timeout = 60 |
|
|
|
u.Timeout = 60 |
|
|
|
|
|
|
|
|
|
|
|
err = bot.UpdatesChan(u) |
|
|
|
err = bot.UpdatesChan(u) |
|
|
|
if err != nil { |
|
|
|
|
|
|
|
log.Panic(err) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for update := range bot.Updates { |
|
|
|
for update := range bot.Updates { |
|
|
|
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) |
|
|
|
log.Printf("[%s] %s", update.Message.From.UserName, update.Message.Text) |
|
|
|
|
|
|
|
|
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) |
|
|
|
msg := tgbotapi.NewMessage(update.Message.Chat.ID, update.Message.Text) |
|
|
|
msg.ReplyToMessageID = update.Message.MessageID |
|
|
|
msg.ReplyToMessageID = update.Message.MessageID |
|
|
|
|
|
|
|
|
|
|
|
bot.Send(msg) |
|
|
|
bot.Send(msg) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
``` |
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
@ -56,7 +53,7 @@ If you need to use webhooks for some reason (such as running on Google App Engin |
|
|
|
package main |
|
|
|
package main |
|
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
import ( |
|
|
|
"github.com/Syfaro/telegram-bot-api" |
|
|
|
"github.com/zhulik/telegram-bot-api" |
|
|
|
"log" |
|
|
|
"log" |
|
|
|
"net/http" |
|
|
|
"net/http" |
|
|
|
) |
|
|
|
) |
|
|
|