52 lines
847 B
Go
52 lines
847 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
|
||
|
"git.fromouter.space/hamcha/tg"
|
||
|
"github.com/spf13/viper"
|
||
|
)
|
||
|
|
||
|
func checkErr(err error, msg string, args ...interface{}) {
|
||
|
if err != nil {
|
||
|
fmt.Printf("FATAL ERROR\n"+msg+":\n ", args...)
|
||
|
fmt.Println(err.Error())
|
||
|
os.Exit(1)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var api *tg.Telegram
|
||
|
|
||
|
func main() {
|
||
|
viper.AutomaticEnv()
|
||
|
|
||
|
bind := viper.GetString("bind")
|
||
|
if bind == "" {
|
||
|
panic("Missing BIND")
|
||
|
}
|
||
|
|
||
|
token := viper.GetString("token")
|
||
|
if token == "" {
|
||
|
panic("Missing TOKEN")
|
||
|
}
|
||
|
|
||
|
webhookURL := viper.GetString("webhookurl")
|
||
|
if webhookURL == "" {
|
||
|
panic("Missing WEBHOOKURL")
|
||
|
}
|
||
|
|
||
|
webhookPath := viper.GetString("webhookpath")
|
||
|
if webhookURL == "" {
|
||
|
panic("Missing WEBHOOKPATH")
|
||
|
}
|
||
|
|
||
|
api = tg.MakeAPIClient(token)
|
||
|
api.SetWebhook(webhookURL)
|
||
|
api.HandleWebhook(bind, webhookPath, webhook)
|
||
|
}
|
||
|
|
||
|
func webhook(update tg.APIUpdate) {
|
||
|
|
||
|
}
|