parent
2e1ca6b96f
commit
d835e47024
@ -0,0 +1,42 @@ |
|||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"log" |
||||||
|
"time" |
||||||
|
|
||||||
|
tb "gopkg.in/tucnak/telebot.v2" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
var ( |
||||||
|
port = os.Getenv("PORT") |
||||||
|
publicURL = os.Getenv("PUBLIC_URL") // you must add it to your config vars
|
||||||
|
token = os.Getenv("TOKEN") // you must add it to your config vars
|
||||||
|
) |
||||||
|
|
||||||
|
webhook := &tb.Webhook{ |
||||||
|
Listen: ":" + port, |
||||||
|
Endpoint: &tb.WebhookEndpoint{PublicURL: publicURL}, |
||||||
|
} |
||||||
|
|
||||||
|
pref := tb.Settings{ |
||||||
|
Token: token, |
||||||
|
Poller: webhook, |
||||||
|
} |
||||||
|
|
||||||
|
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() |
||||||
|
} |
Loading…
Reference in new issue