generated from 42ip/template
-
Notifications
You must be signed in to change notification settings - Fork 2
/
generateList.py
42 lines (41 loc) · 1.11 KB
/
generateList.py
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
import sys,os
arr = []
files = os.listdir(sys.path[0] + '/stickersraw')
st = "{{$a := index .CmdArgs 0 }} \n"
st += "{{$b := cslice "
names = []
for fileName in files:
names.append(fileName.split('.')[0])
names = sorted(names)
n = ""
for name in names:
n += "\"" + name + "\" "
st += n
st += """ }}
{{if or (eq $a "stickers") (eq $a "gifs") (eq $a "gif") (eq $a "gifss") }}
{{deleteTrigger 0 }}
{{if eq (len .Args) 1}}
{{$r := joinStr " " $b.StringSlice}}
{{$r}}
{{else if eq (len .Args) 2}}
{{$c := index .CmdArgs 1}}
{{$s := cslice " " }}
{{range $index,$value := $b}}
{{- if or (hasPrefix $value $c) ( and (eq $a "gifss" ) ( reFind $c $value ) ) -}}
{{$s = $s.Append $value}}
{{- end -}}
{{- end}}
{{$r := joinStr " " $s.StringSlice}}
{{$r := str $r}}
{{$r}}
{{ deleteResponse 30 }}
{{end}}
{{end}}
{{range $b}}
{{- if eq . $a -}}
{{- $link := joinStr "" "https://github.com/42ip/animatedStickersDB/blob/main/stickersraw/" $a ".gif?raw=true" -}}
{{- $link -}}
{{- end -}}
{{- end}}"""
with open(sys.path[0] + "/output.yag", "w") as text_file:
text_file.write(st)