-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.go
52 lines (43 loc) · 1.21 KB
/
server.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"encoding/json"
"fmt"
"net/http"
"net/url"
)
// The mattermost thing
type Notification struct {
Text string `json:"text"`
ResponseType string `json:"response_type"`
GotoLocation string `json:"goto_location"`
}
// The serverino
func MiniServer(w http.ResponseWriter, r *http.Request) {
err := r.ParseForm()
if err != nil {
panic(err)
}
address := getEncodedAddress(r.FormValue("text"))
text := fmt.Sprintf(`🚨 **Hey beautiful souls!** 🚨
If you're free, we’ve got a videoconference happening today, and I’d love for you to join! 🎥💻
🗓️ **When?** Today
⏰ **Time?** Right now (or whenever you're ready, coffee ☕️ in hand)
💻 **Where?** %s
It'll be great to have you there—let's connect and make it a good one! 💫💬
– *[%s]* 😊✨
`, address, r.FormValue("user_name"))
data := Notification{text, "in_channel", address}
w.Header().Set("Content-type", "application/json")
err = json.NewEncoder(w).Encode(&data)
if err != nil {
panic(err)
}
}
func getEncodedAddress(path string) string {
baseURL, err := url.Parse("https://vdc.dyne.org")
if err != nil {
fmt.Println("Malformed URL: ", err.Error())
}
baseURL.Path += path
return baseURL.String()
}