2016-04-03 17:59:27 +00:00
|
|
|
|
package v1
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"math/rand"
|
|
|
|
|
"time"
|
|
|
|
|
|
2019-02-25 21:04:55 +00:00
|
|
|
|
"github.com/osuyozora/api/common"
|
2016-04-03 17:59:27 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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{
|
|
|
|
|
"Proudly sponsored by Kirotuso!",
|
|
|
|
|
"The brace is on fire!",
|
|
|
|
|
"deverupa ga daisuki!",
|
|
|
|
|
"It works!!!!",
|
|
|
|
|
"Feelin' groovy!",
|
|
|
|
|
"sudo rm -rf /",
|
|
|
|
|
"Hi! I'm Flowey! Flowey the flower!",
|
|
|
|
|
"Ripple devs are actually cats",
|
2016-04-16 16:05:24 +00:00
|
|
|
|
"Support Howl's fund for buying a power supply for his SSD!",
|
|
|
|
|
"Superman dies",
|
|
|
|
|
"PP when?",
|
|
|
|
|
"RWC hype",
|
2017-06-13 08:03:08 +00:00
|
|
|
|
"I'd just like to interject for a moment.",
|
|
|
|
|
"Running on an apple pie!",
|
|
|
|
|
":thinking:",
|
|
|
|
|
"The total entropy of an isolated system can only increase over time",
|
|
|
|
|
"Where are my testicles, Summer?",
|
|
|
|
|
"Why don't you ask the smartest people in the universe? Oh yeah, you can't. They blew up.",
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func surpriseMe() string {
|
2017-02-02 14:13:17 +00:00
|
|
|
|
n := int(time.Now().UnixNano())
|
|
|
|
|
return randomSentences[n%len(randomSentences)] + " " + kaomojis[n%len(kaomojis)]
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-16 16:05:24 +00:00
|
|
|
|
type pingResponse struct {
|
|
|
|
|
common.ResponseBase
|
2016-09-02 23:31:03 +00:00
|
|
|
|
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"`
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-04 12:36:37 +00:00
|
|
|
|
// PingGET is a message to check with the API that we are logged in, and know what are our privileges.
|
2016-04-16 16:05:24 +00:00
|
|
|
|
func PingGET(md common.MethodData) common.CodeMessager {
|
|
|
|
|
var r pingResponse
|
2016-04-03 17:59:27 +00:00
|
|
|
|
r.Code = 200
|
2016-04-16 16:05:24 +00:00
|
|
|
|
|
2016-04-08 17:05:54 +00:00
|
|
|
|
if md.ID() == 0 {
|
2016-06-14 22:23:55 +00:00
|
|
|
|
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))]
|
2016-04-03 17:59:27 +00:00
|
|
|
|
} else {
|
|
|
|
|
r.Message = surpriseMe()
|
|
|
|
|
}
|
2016-04-16 16:05:24 +00:00
|
|
|
|
|
|
|
|
|
r.ID = md.ID()
|
2016-09-02 23:31:03 +00:00
|
|
|
|
r.Privileges = md.User.TokenPrivileges
|
|
|
|
|
r.UserPrivileges = md.User.UserPrivileges
|
|
|
|
|
r.PrivilegesS = md.User.TokenPrivileges.String()
|
|
|
|
|
r.UserPrivilegesS = md.User.UserPrivileges.String()
|
2016-04-16 16:05:24 +00:00
|
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type surpriseMeResponse struct {
|
|
|
|
|
common.ResponseBase
|
|
|
|
|
Cats [100]string `json:"cats"`
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-04 12:36:37 +00:00
|
|
|
|
// SurpriseMeGET generates cute cats.
|
2016-04-03 17:59:27 +00:00
|
|
|
|
//
|
|
|
|
|
// ... Yes.
|
2016-04-16 16:05:24 +00:00
|
|
|
|
func SurpriseMeGET(md common.MethodData) common.CodeMessager {
|
|
|
|
|
var r surpriseMeResponse
|
2016-04-03 17:59:27 +00:00
|
|
|
|
r.Code = 200
|
|
|
|
|
for i := 0; i < 100; i++ {
|
2016-04-16 16:05:24 +00:00
|
|
|
|
r.Cats[i] = surpriseMe()
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|
2016-04-16 16:05:24 +00:00
|
|
|
|
return r
|
2016-04-03 17:59:27 +00:00
|
|
|
|
}
|