-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.go
462 lines (417 loc) · 9.01 KB
/
utils.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
package avatar
import "github.com/gomig/utils"
func filterKeys(legalItems []string, items []string) []string {
res := make([]string, 0)
for _, i := range items {
if utils.Contains(legalItems, i) {
res = append(res, i)
}
}
return res
}
// shapeKeys get registered shape names
func shapeKeys() []string {
keys := make([]string, 0)
for k := range shapes {
keys = append(keys, k)
}
return keys
}
// resolveShape get registered shape data
//
// @return shape, mask
func resolveShape(name string) (string, string) {
if v, ok := shapes[name]; ok {
return v.shape, v.mask
}
return "", ""
}
// resolveLetterShape get letter shape
// return fallback shape if letter not found
//
// @return shape
func resolveLetterShape(text string) string {
letter := transformLetter(text)
if v, ok := letters[letter]; ok {
return v
}
if v, ok := letters[Default]; ok {
return v
}
return ""
}
// stickerKeys get registered sticker names
func stickerKeys() []string {
keys := make([]string, 0)
for k := range stickers {
keys = append(keys, k)
}
return keys
}
// resolveSticker get registered sticker
// return default sticker if not found
//
// @return sticker
func resolveSticker(name string) string {
if v, ok := stickers[name]; ok {
return v
}
if v, ok := stickers[Default]; ok {
return v
}
return ""
}
// hairColorKeys get registered hair color names
func hairColorKeys() []string {
keys := make([]string, 0)
for k := range hairColors {
keys = append(keys, k)
}
return keys
}
// resolveHairColor get registered hair color
// return default hair color if not found
//
// @return base, highlight
func resolveHairColor(name string) hairColorType {
if v, ok := hairColors[name]; ok {
return v
}
if v, ok := hairColors[Default]; ok {
return v
}
return defaultHairColor
}
// skinColorKeys get registered skin color names
func skinColorKeys() []string {
keys := make([]string, 0)
for k := range skinColors {
keys = append(keys, k)
}
return keys
}
// resolveSkinColor get registered skin color
// return default skin color if not found
//
// @return skinColor
func resolveSkinColor(name string) skinColorType {
if v, ok := skinColors[name]; ok {
return v
}
if v, ok := skinColors[Default]; ok {
return v
}
return defaultSkinColor
}
// paletteKeys get registered palette names
func paletteKeys() []string {
keys := make([]string, 0)
for k := range palettes {
keys = append(keys, k)
}
return keys
}
// resolvePalette get registered palette
// return default palette if not found
//
// @return palette
func resolvePalette(name string) paletteType {
if v, ok := palettes[name]; ok {
return v
}
if v, ok := palettes[Default]; ok {
return v
}
return defaultPalette
}
// facialHairKeys get registered facial hair names
func facialHairKeys() []string {
keys := make([]string, 0)
for k := range facialHairs {
keys = append(keys, k)
}
return keys
}
// resolveFacialHair get registered facial hair
//
// @return facial hair
func resolveFacialHair(name string) string {
if v, ok := facialHairs[name]; ok {
return v
}
return ""
}
// maleHairKeys get registered hair name for mans
func maleHairKeys() []string {
keys := make([]string, 0)
for k := range maleHairs {
keys = append(keys, k)
}
return keys
}
// resolveMaleHair get registered hair for man
//
// @return hair
func resolveMaleHair(name string) string {
if v, ok := maleHairs[name]; ok {
return v
}
return ""
}
// femaleHairKeys get registered hair name for womans
func femaleHairKeys() []string {
keys := make([]string, 0)
for k := range femaleHairs {
keys = append(keys, k)
}
return keys
}
// resolveFemaleHair get registered hair for woman
//
// @return hair
func resolveFemaleHair(name string) string {
if v, ok := femaleHairs[name]; ok {
return v
}
return ""
}
// maleDressKeys get registered dress name for mans
func maleDressKeys() []string {
keys := make([]string, 0)
for k := range maleDresses {
keys = append(keys, k)
}
return keys
}
// resolveMaleDress get registered dress for man
// return default dress if not found
//
// @return dress
func resolveMaleDress(name string) string {
if v, ok := maleDresses[name]; ok {
return v
}
if v, ok := maleDresses[Default]; ok {
return v
}
return ""
}
// femaleDressKeys get registered dress name for womans
func femaleDressKeys() []string {
keys := make([]string, 0)
for k := range femaleDresses {
keys = append(keys, k)
}
return keys
}
// resolveFemaleDress get registered dress for woman
// return default dress if not found
//
// @return dress
func resolveFemaleDress(name string) string {
if v, ok := femaleDresses[name]; ok {
return v
}
if v, ok := femaleDresses[Default]; ok {
return v
}
return ""
}
// maleEyeKeys get registered eye name for mans
func maleEyeKeys() []string {
keys := make([]string, 0)
for k := range maleEyes {
keys = append(keys, k)
}
return keys
}
// resolveMaleEye get registered eye for man
// return default eye if not found
//
// @return eye
func resolveMaleEye(name string) string {
if v, ok := maleEyes[name]; ok {
return v
}
if v, ok := maleEyes[Default]; ok {
return v
}
return ""
}
// femaleEyeKeys get registered eye name for womans
func femaleEyeKeys() []string {
keys := make([]string, 0)
for k := range femaleEyes {
keys = append(keys, k)
}
return keys
}
// resolveFemaleEye get registered eye for woman
// return default eye if not found
//
// @return eye
func resolveFemaleEye(name string) string {
if v, ok := femaleEyes[name]; ok {
return v
}
if v, ok := femaleEyes[Default]; ok {
return v
}
return ""
}
// maleEyebrowKeys get registered eyebrow name for mans
func maleEyebrowKeys() []string {
keys := make([]string, 0)
for k := range maleEyebrows {
keys = append(keys, k)
}
return keys
}
// resolveMaleEyebrow get registered eyebrow for man
// return default eyebrow if not found
//
// @return eyebrow
func resolveMaleEyebrow(name string) string {
if v, ok := maleEyebrows[name]; ok {
return v
}
if v, ok := maleEyebrows[Default]; ok {
return v
}
return ""
}
// femaleEyebrowKeys get registered eyebrow name for womans
func femaleEyebrowKeys() []string {
keys := make([]string, 0)
for k := range femaleEyebrows {
keys = append(keys, k)
}
return keys
}
// resolveFemaleEyebrow get registered eyebrow for woman
// return default eyebrow if not found
//
// @return eyebrow
func resolveFemaleEyebrow(name string) string {
if v, ok := femaleEyebrows[name]; ok {
return v
}
if v, ok := femaleEyebrows[Default]; ok {
return v
}
return ""
}
// maleMouthKeys get registered mouth name for mans
func maleMouthKeys() []string {
keys := make([]string, 0)
for k := range maleMouths {
keys = append(keys, k)
}
return keys
}
// resolveMaleMouth get registered mouth for man
// return default mouth if not found
//
// @return mouth
func resolveMaleMouth(name string) string {
if v, ok := maleMouths[name]; ok {
return v
}
if v, ok := maleMouths[Default]; ok {
return v
}
return ""
}
// femaleMouthKeys get registered mouth name for womans
func femaleMouthKeys() []string {
keys := make([]string, 0)
for k := range femaleMouths {
keys = append(keys, k)
}
return keys
}
// resolveFemaleMouth get registered mouth for woman
// return default mouth if not found
//
// @return mouth
func resolveFemaleMouth(name string) string {
if v, ok := femaleMouths[name]; ok {
return v
}
if v, ok := femaleMouths[Default]; ok {
return v
}
return ""
}
// maleGlassKeys get registered glass name for mans
func maleGlassKeys() []string {
keys := make([]string, 0)
for k := range maleGlasses {
keys = append(keys, k)
}
return keys
}
// resolveMaleGlass get registered glass for man
// return default glass if not found
//
// @return glass
func resolveMaleGlass(name string) string {
if v, ok := maleGlasses[name]; ok {
return v
}
return ""
}
// femaleGlassKeys get registered glass name for womans
func femaleGlassKeys() []string {
keys := make([]string, 0)
for k := range femaleGlasses {
keys = append(keys, k)
}
return keys
}
// resolveFemaleGlass get registered glass for woman
// return default glass if not found
//
// @return glass
func resolveFemaleGlass(name string) string {
if v, ok := femaleGlasses[name]; ok {
return v
}
return ""
}
// maleAccessoryKeys get registered accessory name for mans
func maleAccessoryKeys() []string {
keys := make([]string, 0)
for k := range maleAccessories {
keys = append(keys, k)
}
return keys
}
// resolveMaleAccessory get registered accessory for man
// return default accessory if not found
//
// @return accessory
func resolveMaleAccessory(name string) string {
if v, ok := maleAccessories[name]; ok {
return v
}
return ""
}
// femaleAccessoryKeys get registered accessory name for womans
func femaleAccessoryKeys() []string {
keys := make([]string, 0)
for k := range femaleAccessories {
keys = append(keys, k)
}
return keys
}
// resolveFemaleAccessory get registered accessory for woman
// return default accessory if not found
//
// @return accessory
func resolveFemaleAccessory(name string) string {
if v, ok := femaleAccessories[name]; ok {
return v
}
return ""
}