-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail.go
79 lines (70 loc) · 1.51 KB
/
mail.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
package nico
import "strings"
// Comment color.
const (
CommentColorWhite = "white"
CommentColorRed = "red"
CommentColorPink = "pink"
CommentColorOrange = "orange"
CommentColorYellow = "yellow"
CommentColorGreen = "green"
CommentColorCyan = "cyan"
CommentColorBlue = "blue"
CommentColorPurple = "purple"
)
// Comment size.
const (
SizeMedium = "medium"
SizeBig = "big"
SizeSmall = "small"
)
// Comment position.
const (
PositionNaka = "naka"
PositionUe = "ue"
PositionShita = "shita"
)
var validateCommentColorMap = map[string]bool{
CommentColorWhite: true,
CommentColorRed: true,
CommentColorPink: true,
CommentColorOrange: true,
CommentColorYellow: true,
CommentColorGreen: true,
CommentColorCyan: true,
CommentColorBlue: true,
CommentColorPurple: true,
}
var validateSizeMap = map[string]bool{
SizeMedium: true,
SizeBig: true,
SizeSmall: true,
}
var validatePositionMap = map[string]bool{
PositionNaka: true,
PositionUe: true,
PositionShita: true,
}
// Mail is a structure that specifies comment options.
type Mail struct {
Is184 bool
CommentColor string
Size string
Position string
}
func (m Mail) String() string {
var strs []string
if m.Is184 {
strs = append(strs, "184")
}
if validateCommentColorMap[m.CommentColor] {
strs = append(strs, m.CommentColor)
}
if validateSizeMap[m.Size] {
strs = append(strs, m.Size)
}
if validatePositionMap[m.Position] {
strs = append(strs, m.Position)
}
return strings.Join(strs, " ")
}