forked from dpb587/go-slack-topic-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
credhub.go
72 lines (59 loc) · 1.54 KB
/
credhub.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"log"
"os"
"strings"
"time"
"github.com/dpb587/go-slack-topic-bot/message"
"github.com/dpb587/go-slack-topic-bot/message/pairist"
"github.com/martys34/go-slack-topic-bot/slack"
)
func main() {
pivotalTeam := pairist.PeopleInRole{
Team: "therealslimcredhub",
Role: "Bat-person",
People: map[string]string{
"Andrew": "U8RH9A30R",
"Mark": "U05661PTK",
"Marty": "UBXEUQN6P",
"Josh": "U1V6C2UKW",
"Tom": "UG262F4EB",
"Victoria": "U6SUTRCKB",
},
}
interruptPair, _ := pivotalTeam.Message()
if time.Now().Weekday() == time.Weekday(5) {
err := slack.SendMessage(interruptPair,
"don't forget to spin the feedback wheel! :fidgetspinner:\nhttps://tinyurl.com/credhubfeedback")
if err != nil {
log.Panicf("ERROR: %v", err)
}
}
}
func createChannelMessage(workspace, firstLine string, team pairist.PeopleInRole, PM []string) {
pmString := strings.Join(PM, ", ")
msg, err := message.Join(
" | ",
message.Literal(firstLine),
message.Prefix(
"interrupt: ",
message.Conditional(
pairist.WorkingHours("09:00", "18:00", "America/New_York"),
message.Join(
" ",
team,
message.Literal("| break glass: `@credhub-team` |"),
message.Literal("PM: "+pmString),
),
),
),
).Message()
if err != nil {
log.Panicf("ERROR: %v", err)
}
log.Printf("DEBUG: expected message: %s", msg)
err = slack.UpdateChannelTopic(os.Getenv(workspace+"_SLACK_CHANNEL"), os.Getenv(workspace+"_SLACK_TOKEN"), msg)
if err != nil {
log.Panicf("ERROR: %v", err)
}
}