This repository has been archived by the owner on Mar 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathboobs_controller.go
158 lines (120 loc) · 2.99 KB
/
boobs_controller.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
151
152
153
154
155
156
157
158
package main
import (
"fmt"
"math/rand"
"net/http"
"os"
"strconv"
"time"
"github.com/DataDog/datadog-go/statsd"
"github.com/gin-gonic/gin"
)
var boobList = []string{
"( o y o )", "( . y . )", "( O Y O )",
"( O Y o )", "\\./\\./", "(*Y*)", "( . Y . )",
"(.Y.)", "(。 ㅅ 。)", "(@ㅅ@)", "(•_ㅅ_•)",
"(o)(o)", "(•)(•)", "(.)(.)(.)", "[○][°]",
"[°][○]", "( o Y O )", "( + )( + )", "oo",
"{ O }{ O }", "( ^ )( ^ )", "(Q)(O)", "(O)(Q)",
"(p)(p)", "\\o/\\o/", "( - )( - )"}
var boobLeftSides = []string{
"{", "(", "[", "\\",
}
var boobRightSides = []string{
"}", ")", "]", "/",
}
var boobCracks = []string{
"y", "Y", "/\\", "ㅅ", ")(", "][", "}{", ")(.)(",
}
var boobNipples = []string{
"o", ".", "O", "0", "。", "+", "p", "-", "*", "•", "^", "°", "○",
}
func getBoobs(c *gin.Context) {
d, err := statsd.New("127.0.0.1:8125")
if err != nil {
fmt.Println(err)
}
defer d.Close()
var key string
d.Namespace = "boobs-api."
d.Tags = append(d.Tags, "ENV:"+os.Getenv("ENVIRONMENT"))
sfw := false
limit := 5000000
if len(c.Request.URL.Query().Get("sfw")) > 0 {
sfw = true
d.Tags = append(d.Tags, "rating:sfw")
key = "boobs_counter_sfw"
} else {
d.Tags = append(d.Tags, "rating:nsfw")
key = "boobs_counter_nsfw"
}
if len(os.Getenv("BOOBS_LIMIT")) > 0 {
var err error
limit, err = strconv.Atoi(os.Getenv("BOOBS_LIMIT"))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": err.Error(),
})
return
}
}
_int, err := strconv.Atoi(c.Param("amount"))
if err != nil {
c.JSON(http.StatusInternalServerError, gin.H{
"message": err.Error(),
})
return
}
if _int > limit {
c.JSON(http.StatusTooManyRequests, gin.H{
"message": "Too Many Boobs, the limit is currently " + strconv.Itoa(limit) + ".",
})
return
}
c.JSON(http.StatusOK, gin.H{
"boobs": genBoobs(_int, sfw),
})
err = d.Count("amount", int64(_int), nil, 1)
if err != nil {
fmt.Println("Unable to send to DD")
}
redisClient.IncrBy(key, int64(_int))
}
func genBoobs(amount int, sfw bool) []string {
rand.Seed(time.Now().Unix())
var boob string
var boobs []string
for i := 0; i < amount; i++ {
if sfw {
boob = "(omit)(omit)"
} else {
boob = getLeftSide() + getSpacing() + getNipple() + getSpacing() + getCrack() + getSpacing() + getNipple() + getSpacing() + getRightSide()
}
boobs = append(boobs, boob)
}
return boobs
}
func getLeftSide() string {
rand.Seed(time.Now().UnixNano())
return boobLeftSides[rand.Intn(len(boobLeftSides))]
}
func getRightSide() string {
rand.Seed(time.Now().UnixNano())
return boobRightSides[rand.Intn(len(boobRightSides))]
}
func getCrack() string {
rand.Seed(time.Now().UnixNano())
return boobCracks[rand.Intn(len(boobCracks))]
}
func getNipple() string {
rand.Seed(time.Now().UnixNano())
return boobNipples[rand.Intn(len(boobNipples))]
}
func getSpacing() string {
rand.Seed(time.Now().UnixNano())
spaces := ""
for i := 0; i < rand.Intn(2); i++ {
spaces += " "
}
return spaces
}