This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
forked from osuthailand/api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ping.go
150 lines (137 loc) · 3.67 KB
/
ping.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
package v1
import (
"math/rand"
"time"
"github.com/osuthailand/api/common"
)
var rn = rand.New(rand.NewSource(time.Now().UnixNano()))
var kaomojis = [...]string{
"Σ(ノ°▽°)ノ",
"( ƅ°ਉ°)ƅ",
"ヽ( ・∀・)ノ",
"˭̡̞(◞⁎˃ᆺ˂)◞*✰",
"(p^-^)p",
"(ノ^∇^)ノ゚",
"ヽ(〃・ω・)ノ",
"(۶* ‘ꆚ’)۶”",
"(。>ω<)。",
"(ノ。≧◇≦)ノ",
"ヾ(。・ω・)シ",
"(ノ・д・)ノ",
".+:。(ノ・ω・)ノ゙",
"Σ(*ノ´>ω<。`)ノ",
"ヾ(〃^∇^)ノ♪",
"\(@ ̄∇ ̄@)/",
"\(^▽^@)ノ",
"ヾ(@^▽^@)ノ",
"(((\(@v@)/)))",
"\(*T▽T*)/",
"\(^▽^)/",
"\(T∇T)/",
"ヽ( ★ω★)ノ",
"ヽ(;▽;)ノ",
"ヾ(。◕ฺ∀◕ฺ)ノ",
"ヾ(@† ▽ †@)ノ",
"ヾ(@^∇^@)ノ",
"ヾ(@^▽^@)ノ",
"ヾ(@^▽^@)ノ",
"ヾ(@゜▽゜@)ノ",
"(.=^・ェ・^=)",
"((≡^⚲͜^≡))",
"(^・o・^)ノ”",
"(^._.^)ノ",
"(^人^)",
"(=;ェ;=)",
"(=`ω´=)",
"(=`ェ´=)",
"(=´∇`=)",
"(=^・^=)",
"(=^・ェ・^=)",
"(=^‥^=)",
"(=TェT=)",
"(=xェx=)",
"\(=^‥^)/’`",
"~(=^‥^)/",
"└(=^‥^=)┐",
"ヾ(=゚・゚=)ノ",
"ヽ(=^・ω・^=)丿",
"d(=^・ω・^=)b",
"o(^・x・^)o",
"V(=^・ω・^=)v",
"(⁎˃ᆺ˂)",
"(,,^・⋏・^,,)",
}
var randomSentences = [...]string{
"osu!thailand? What is that?",
"The brace is on fire!",
"deverupa ga daisuki!",
"It works!!!!",
"Feelin' groovy!",
"sudo rm -rf / (wait... did i forgot something here?)",
"Momma, I don't wanna die",
"Aoba haven't watch anime for 1 year",
"I don't have money to buy new laptop",
"This API is skidded :OMEGALUL:",
"Relax server, yes.",
"AWC hype Pepega",
"Daisuki~",
"Ainu Client is a big meme? nahh",
":thonk:",
"If you love me, then say so!",
"Recommend me something.",
"Hi, this is Aoba stuff",
"Despacito 2019 v2",
"ilyt, are you reading this?",
"jackson... i'm sorry... for everything...",
"Simon, u broke relax profile ~Aoba 2019",
"All we had to do was follow the damn train, CJ.",
"Free supporter for Thai people!",
"fake ass 5* map ~Aoffy 2019",
"im bad at osu ~Aoba 2019",
"WHAT ARE YOU DOING?!",
"Are you reading this btw?",
"donate me pls im poor",
}
func surpriseMe() string {
n := int(time.Now().UnixNano())
return randomSentences[n%len(randomSentences)] + " " + kaomojis[n%len(kaomojis)]
}
type pingResponse struct {
common.ResponseBase
ID int `json:"user_id"`
Privileges common.Privileges `json:"privileges"`
UserPrivileges common.UserPrivileges `json:"user_privileges"`
PrivilegesS string `json:"privileges_string"`
UserPrivilegesS string `json:"user_privileges_string"`
}
// PingGET is a message to check with the API that we are logged in, and know what are our privileges.
func PingGET(md common.MethodData) common.CodeMessager {
var r pingResponse
r.Code = 200
if md.ID() == 0 {
r.Message = "You have not given us a token, so we don't know who you are! But you can still login with POST /tokens " + kaomojis[rn.Intn(len(kaomojis))]
} else {
r.Message = surpriseMe()
}
r.ID = md.ID()
r.Privileges = md.User.TokenPrivileges
r.UserPrivileges = md.User.UserPrivileges
r.PrivilegesS = md.User.TokenPrivileges.String()
r.UserPrivilegesS = md.User.UserPrivileges.String()
return r
}
type surpriseMeResponse struct {
common.ResponseBase
Cats [100]string `json:"cats"`
}
// SurpriseMeGET generates cute cats.
//
// ... Yes.
func SurpriseMeGET(md common.MethodData) common.CodeMessager {
var r surpriseMeResponse
r.Code = 200
for i := 0; i < 100; i++ {
r.Cats[i] = surpriseMe()
}
return r
}