forked from didinst/tg-bot-example
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
713 B
44 lines
713 B
package main
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
|
|
tb "gopkg.in/tucnak/telebot.v2"
|
|
)
|
|
|
|
func main() {
|
|
var (
|
|
port = os.Getenv("PORT")
|
|
publicURL = os.Getenv("PUBLIC_URL")
|
|
token = os.Getenv("TOKEN")
|
|
apiURL = os.Getenv("API_URL")
|
|
)
|
|
|
|
webhook := &tb.Webhook{
|
|
Listen: ":" + port,
|
|
Endpoint: &tb.WebhookEndpoint{PublicURL: publicURL},
|
|
}
|
|
|
|
pref := tb.Settings{
|
|
Token: token,
|
|
Poller: webhook,
|
|
URL: apiURL,
|
|
}
|
|
|
|
b, err := tb.NewBot(pref)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
return
|
|
}
|
|
|
|
b.Handle("/hello", func(m *tb.Message) {
|
|
b.Send(m.Sender, "Hello World!")
|
|
})
|
|
|
|
b.Start()
|
|
} |