blacklist_add nick reason if blacklist_check nick return FileAppend ni

 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
blacklist_add(nick, reason)
{
if (!blacklist_check(nick))
return
FileAppend, % nick "|" reason "`n", % A_ScriptDir "/blacklist.txt", % "UTF-8"
}
blacklist_check(nick)
{
file := FileOpen(A_ScriptDir "/blacklist.txt", "r"), text := StrSplit(file.Read(), "`r`n"), file.Close()
for k, v in text
{
str := StrSplit(v, "|")
if (str[1] == nick)
return str
}
return 0
}
blacklist_del(nick)
{
file := FileOpen(A_ScriptDir "/blacklist.txt", "r"), text := StrSplit(file.Read(), "`r`n"), file.Close()
new := ""
for k, v in text
{
str := StrSplit(v, "|")
if (str[1] != nick)
new .= v "`n"
}
FileDelete, A_ScriptDir "/blacklist.txt"
FileAppend, % new, % A_ScriptDir "/blacklist.txt", % "UTF-8"
}