blob: 9632cf005619a667a030e2a4040314f8ded7d003 (
plain) (
tree)
|
|
package main
import (
"crypto/tls"
"encoding/json"
"fmt"
"github.com/labstack/echo"
"log"
"net/http"
)
func main() {
//token := os.Getenv("TOKEN")
e := echo.New()
e.POST("/events-endpoint", func(c echo.Context) error {
ev := struct {
Payload string `form:"payload"`
}{}
c.Bind(&ev)
pl := &payload{}
if err := json.Unmarshal([]byte(ev.Payload), pl); err != nil {
return err
}
// TODO how to get members???
//members, err := getUsers(token, pl.Channel.ID)
//if err != nil {
// return err
//}
members := []string{
"U8UJT0UJX",
"UCF7JA5CZ",
"UC86HMG1G",
"UCFHM9G04",
"UC9GZ0C2J",
}
member := getRandomMember(members, pl.User.ID)
text := fmt.Sprintf("Назначен: <@%s>", member)
return sendMessage(pl.ResponseUrl, pl.Message.Text, text)
})
if err := e.Start(":3000"); err != nil {
log.Fatalln(err)
}
}
func getClient() *http.Client {
transCfg := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
return &http.Client{Transport: transCfg}
}
|