ripple-api/app/v1/ping.go
Howl e4d27f8d6b Allow users with AdminManageUsers to see banned users
Also:
- General code refactoring
- Allow banned/restricted users to see their scores etc
- common.MethodData now contains UserPrivileges
- UserPrivileges have now their own type
- Implement md.HasQuery, to know if there's a GET querystring parameter or not
2016-08-27 12:04:12 +02:00

127 lines
2.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package v1
import (
"math/rand"
"time"
"git.zxq.co/ripple/rippleapi/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{
"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",
"Support Howl's fund for buying a power supply for his SSD!",
"Superman dies",
"PP when?",
"RWC hype",
}
func surpriseMe() string {
return randomSentences[rn.Intn(len(randomSentences))] + " " + kaomojis[rn.Intn(len(kaomojis))]
}
type pingResponse struct {
common.ResponseBase
ID int `json:"user_id"`
Privileges uint64 `json:"privileges"`
}
// 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 = uint64(md.User.TokenPrivileges)
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
}