ripple-api/app/v1/ping.go

117 lines
2.6 KiB
Go
Raw Normal View History

2016-04-03 17:59:27 +00:00
package v1
import (
"math/rand"
"time"
"github.com/osuripple/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{
"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",
}
func surpriseMe() string {
return randomSentences[rn.Intn(len(randomSentences))] + " " + kaomojis[rn.Intn(len(kaomojis))]
}
type pingData struct {
ID int `json:"user_id"`
Privileges int `json:"privileges"`
}
// Ping is a message to check with the API that we are logged in, and know what are our privileges.
func Ping(md common.MethodData) (r common.Response) {
r.Code = 200
if md.User.UserID == 0 {
r.Message = "You have not given us a token, so we don't know who you are! But you can still login with /api/v1/login " + kaomojis[rn.Intn(len(kaomojis))]
} else {
r.Message = surpriseMe()
}
r.Data = pingData{
ID: md.User.UserID,
Privileges: int(md.User.Privileges),
}
return
}
// SurpriseMe generates cute cats.
//
// ... Yes.
func SurpriseMe(md common.MethodData) (r common.Response) {
r.Code = 200
cats := make([]string, 100)
for i := 0; i < 100; i++ {
cats[i] = surpriseMe()
}
r.Data = cats
return
}