-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.cr
54 lines (43 loc) · 876 Bytes
/
server.cr
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
require "./slack"
require "kemal"
get "/" do
slack = Slack.new
snoozed = slack.snoozed?
status = slack.status_text
render "views/index.ecr", "views/layout.ecr"
end
post "/" do |env|
if env.params.body.has_key? "snooze"
Slack.new.toggle_snooze
elsif env.params.body.has_key? "pair"
Slack.new.lets_pair
elsif env.params.body.has_key? "run"
Slack.new.gonna_run
end
env.redirect("/")
end
get "/api/status" do
slack = Slack.new
slack.snoozed? ? "1" : "0"
end
get "/api/on" do
Slack.new.dnd_on
end
get "/api/off" do
Slack.new.dnd_off
end
get "/api/pair" do
Slack.new.lets_pair
end
get "/api/pairing" do
slack = Slack.new
slack.status_emoji == ":rubberduck:" ? "1" : "0"
end
get "/api/run" do
Slack.new.gonna_run
end
get "/api/running" do
slack = Slack.new
slack.status_emoji == ":runner:" ? "1" : "0"
end
Kemal.run(6789)