; Quotes v2.9 - by entropy 2019
; syntax: !addquote <text> to add to it
; syntax: !quote [N/*wildcard*]
; syntax: !quotes
; syntax: !whoquote [N]
; syntax: !delquote [N]
#quotes on
alias -l unsafe return $!decode( $encode($1-,m) ,m)
alias quotesfile { return $qt($+($scriptdir,quotes,.,$network,.,#,.txt)) }
alias -l doquotes {
var %chan = $mid(#,2)
if (?quote iswm $1 && $left($1,1) isin @!.) {
if (!$2) {
var %a = $rand(1,$lines($quotesfile))
if (%a != $null && $lines($quotesfile) >= 1) { .timerquote -o 1 1 msg $unsafe( # ) $+(%a,$chr(41)) $unsafe( $gettok($read($quotesfile,n,%a),2-,32) ) }
else { .timerquote -o 1 1 msg $unsafe( # ) No quotes! }
}
elseif (* isin $2) {
var %a = 1, %b, %total = 0, %found
while ($read($quotesfile,n,%a)) {
%b = $v1
if ($2 iswm %b && !$istok(%found,%a,32)) { inc %total | %found = %found %a }
inc %a
}
if (%found) {
if (%total > 5) { .timerquote -o 1 1 msg $unsafe( # ) Search criteria too broad! }
elseif (%total == 1) { .timerquote -o 1 1 msg $unsafe( # ) $+(%found,$chr(41)) $unsafe( $gettok($read($quotesfile,n,%found),2-,32) ) }
else { .timerquote -o 1 1 msg $unsafe( # ) Found: %found }
}
else { .timerquote -o 1 1 msg $unsafe( # ) No such quote! }
}
elseif ($2 isnum) {
if ($read($quotesfile,n,$2)) { .timerquote -o 1 1 msg $unsafe( # ) $+($2,$chr(41)) $unsafe( $gettok($v1,2-,32) ) }
else { .timerquote -o 1 1 msg $unsafe( # ) No such quote! }
}
else { .timerquote -o 1 1 msg $unsafe( # ) No such quote! }
}
elseif (?addquote iswm $1 && $left($1,1) isin @!.) {
if (!$2) { .timerquote -o 1 1 msg $unsafe( # ) No Quote Specified! }
else { write $quotesfile $nick $2- | .timerquote -o 1 1 msg $unsafe( # ) Quote: $lines($quotesfile) Added! }
}
elseif (?quotes iswm $1 && $left($1,1) isin @!.) {
.timerquote -o 1 1 msg $unsafe( # ) Quotes: $lines($quotesfile)
}
elseif (?delquote iswm $1 && $left($1,1) isin @!. && $nick isop #) {
if ($read($quotesfile,n,$2) && $2 isnum) {
write $+(-dl,$2) $quotesfile
.timerquote -o 1 1 msg $unsafe( # ) Deleted quote: $qt($2)
}
else { .timerquote -o 1 1 msg $unsafe( # ) No such quote to delete! }
}
elseif (?whoquote iswm $1 && $left($1,1) isin @!.) {
if ($2 isnum && $read($quotesfile,n,$2)) { .timerquote -o 1 1 msg $unsafe( # ) Quote $2 by: $unsafe( $gettok($read($quotesfile,n,$2),1,32) ) }
else { .timerquote -o 1 1 msg $unsafe( # ) No such quote! }
}
}
on *:text:*:#:{ doquotes $1- }
on *:input:#:{ doquotes $1- }
#quotes end