-
Notifications
You must be signed in to change notification settings - Fork 241
/
community_tags.go
94 lines (88 loc) · 2.48 KB
/
community_tags.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
package requests
var TagsEmojies map[string]string
func init() {
TagsEmojies = make(map[string]string)
TagsEmojies["Activism"] = "✊"
TagsEmojies["Art"] = "🎨"
TagsEmojies["Blockchain"] = "🔗"
TagsEmojies["Books & blogs"] = "📚"
TagsEmojies["Career"] = "💼"
TagsEmojies["Collaboration"] = "🤝"
TagsEmojies["Commerce"] = "🛒"
TagsEmojies["Culture"] = "🎎"
TagsEmojies["DAO"] = "🚀"
TagsEmojies["DeFi"] = "📈"
TagsEmojies["Design"] = "🧩"
TagsEmojies["DIY"] = "🔨"
TagsEmojies["Environment"] = "🌿"
TagsEmojies["Education"] = "🎒"
TagsEmojies["Entertainment"] = "🍿"
TagsEmojies["Ethereum"] = "Ξ"
TagsEmojies["Event"] = "🗓"
TagsEmojies["Fantasy"] = "🧙♂️"
TagsEmojies["Fashion"] = "🧦"
TagsEmojies["Food"] = "🌶"
TagsEmojies["Gaming"] = "🎮"
TagsEmojies["Global"] = "🌍"
TagsEmojies["Health"] = "🧠"
TagsEmojies["Hobby"] = "📐"
TagsEmojies["Innovation"] = "🧪"
TagsEmojies["Language"] = "📜"
TagsEmojies["Lifestyle"] = "✨"
TagsEmojies["Local"] = "📍"
TagsEmojies["Love"] = "❤️"
TagsEmojies["Markets"] = "💎"
TagsEmojies["Movies & TV"] = "🎞"
TagsEmojies["Music"] = "🎶"
TagsEmojies["News"] = "🗞"
TagsEmojies["NFT"] = "🖼"
TagsEmojies["Non-profit"] = "🙏"
TagsEmojies["NSFW"] = "🍆"
TagsEmojies["Org"] = "🏢"
TagsEmojies["Pets"] = "🐶"
TagsEmojies["Play"] = "🎲"
TagsEmojies["Podcast"] = "🎙️"
TagsEmojies["Politics"] = "🗳️"
TagsEmojies["Product"] = "🍱"
TagsEmojies["Psyche"] = "🍁"
TagsEmojies["Privacy"] = "👻"
TagsEmojies["Security"] = "🔒"
TagsEmojies["Social"] = "☕"
TagsEmojies["Software dev"] = "👩💻"
TagsEmojies["Sports"] = "⚽️"
TagsEmojies["Tech"] = "📱"
TagsEmojies["Travel"] = "🗺"
TagsEmojies["Vehicles"] = "🚕"
TagsEmojies["Web3"] = "🌐"
}
func ValidateTags(input []string) bool {
for _, t := range input {
_, ok := TagsEmojies[t]
if !ok {
return false
}
}
// False if contains duplicates. Shouldn't have happened
return len(unique(input)) == len(input)
}
func RemoveUnknownAndDeduplicateTags(input []string) []string {
var result []string
for _, t := range input {
_, ok := TagsEmojies[t]
if ok {
result = append(result, t)
}
}
return unique(result)
}
func unique(slice []string) []string {
uniqMap := make(map[string]struct{})
for _, v := range slice {
uniqMap[v] = struct{}{}
}
uniqSlice := make([]string, 0, len(uniqMap))
for v := range uniqMap {
uniqSlice = append(uniqSlice, v)
}
return uniqSlice
}