on *:TEXT:!addlist *:#:{
opchk
var %f = $+(rules\,$mkfn(#),\,$2.txt)
if ($file(%f)) { .notice # $nick $+ , there is already a list with that name for this channel. To see it, type $+(!,$2) | return }
mkdir rules | mkdir rules\ $+ %#
write $qt(%f) $2 $+(list:,$crlf,~~~~~~~~~)
.notice $nick List successfully created. To add items to this list, type !add $2 your_item
describe # announces that $nick created a new list, $qt($2)
}
on *:TEXT:!add & *:#:{
opchk
var %f = $+(rules\,$mkfn(#),\,$2.txt)
if (!$file(%f)) { .notice $nick There is no such list. | describe # announces that $nick tried to add an item to a non-existant list. | return }
if ($read(%f,nw,$3-)) { .notice $nick This item already exists in this list. | return }
write $qt(%f) $3-
.notice # New item has been added to list $qt($2)
}
on *:TEXT:!dellist &:#: {
opchk
var %f = $+(rules\,$mkfn(#),\,$2.txt)
if (!$file(%f)) { .notice $nick List $qt($2) doesn't exist. | describe # announces that $nick tried to delete a non-existant list. | return }
.remove $qt(%f)
.notice $nick List $qt($2) successfully deleted.
}
on *:TEXT:!del & *:#: {
opchk
var %f = $+(rules\,$mkfn(#),\,$2.txt)
if (!$file(%f)) { .notice $nick There is no such list. | describe # announces that $nick tried to delete an item from a non-existant list. | return }
if (!$read(%f,nw,$3-)) { .notice $nick This item doesn't exist in list. | return }
write -dl $+ $readn $qt(%f)
.notice # Item $qt($3) has been deleted from list $qt($2)
}
on $*:TEXT:/^!(\S+)$/S:#: {
var %f = $+(rules\,$mkfn(#),\,$2.txt)
if ($file(%f)) .play $nick $qt(%f) 2000
else .notice $nick No such list.
}
alias -l opchk if ($nick !isop #) { .notice $nick You are not allowed to use this command | halt }