-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwidget_small.go
107 lines (82 loc) · 1.67 KB
/
widget_small.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
package dbl
import "net/url"
type WidgetType int
const (
WidgetStatus WidgetType = iota
WidgetUpvotes
WidgetServers
WidgetLib
)
func (t WidgetType) String() string {
switch t {
case WidgetStatus:
{
return "status"
}
case WidgetUpvotes:
{
return "upvotes"
}
case WidgetServers:
{
return "servers"
}
case WidgetLib:
{
return "lib"
}
default:
{
return "status"
}
}
}
type SmallWidget struct {
Widget
data WidgetData
wType WidgetType
}
func NewSmallWidget() *SmallWidget {
return &SmallWidget{
data: WidgetData{
values: url.Values(make(map[string][]string)),
},
}
}
func (w *SmallWidget) BotID(id string) *SmallWidget {
w.data.botID = id
return w
}
func (w *SmallWidget) Extension(extension Extension) *SmallWidget {
w.data.extension = extension
return w
}
func (w *SmallWidget) WidgetType(wType WidgetType) *SmallWidget {
w.wType = wType
return w
}
func (w *SmallWidget) AvatarBackground(color int64) *SmallWidget {
w.data.setValue("avatarbg", color)
return w
}
func (w *SmallWidget) LeftColor(color int64) *SmallWidget {
w.data.setValue("leftcolor", color)
return w
}
func (w *SmallWidget) RightColor(color int64) *SmallWidget {
w.data.setValue("rightcolor", color)
return w
}
func (w *SmallWidget) LeftTextColor(color int64) *SmallWidget {
w.data.setValue("lefttextcolor", color)
return w
}
func (w *SmallWidget) RightTextColor(color int64) *SmallWidget {
w.data.setValue("righttextcolor", color)
return w
}
func (w *SmallWidget) Generate() string {
u, _ := url.Parse(BaseURL + "widgets/" + w.wType.String() + "/" + w.data.botID + w.data.extension.Ext())
u.RawQuery = w.data.values.Encode()
return u.String()
}