on *:text:!*:#: {
var %alias $mid($1,2)
if ($isalias(%alias)) %alias $nick $chan $2-
/*
Standard for all aliases
var %nick $1
var %chan $2
tokenize 32 $3-
---
if (%!error) halt
:error
msg %chan %error
halt
*/
}
alias quote {
var %file quotes.ini
var %nick $1
var %chan $2
tokenize 32 $remove($3-,$chr(35))
var %items $ini(%file,%chan,0)
if ($1 == add) {
if (!$2) { var %error Can't add quotes without text. | goto error }
inc %items
var %quote $2-
writeini %file %chan %items %quote
msg %chan Added quote $+($chr(35),%items) :: %quote
}
elseif ($1 == del) {
var %item $2
if (!%item) { var %error Can't delete unspecified quote | goto error }
elseif ((%item !isnum) || (%item > %items)) { var %error Can't find quote $+($chr(35),%item) | goto error }
writeini %file %chan %item DELETED
}
elseif ($1 == edit) {
var %item $2
if (!%item) { var %error Can't edit unspecified quote | goto error }
elseif ((%item !isnum) || (%item > %items)) { var %error Can't find quote $+($chr(35),%item) | goto error }
var %quote $3-
writeini %file %chan %item %quote
msg %chan Edited quote $+($chr(35),%item) :: %quote
}
else {
if (!$1) {
var %i 1
while ($true) {
var %item $rand(1,%items)
var %quote $readini(%file,%chan,%item)
if (%quote != DELETED) break
if (%i >= 10) { var %error Tried 10 times, couldn't find a suitable quote. | goto error }
inc %i
}
msg %chan $+($chr(35),%item) :: %quote
}
elseif ($1 isnum) {
var %item $1
if (%item > %items) { var %error Can't find quote $+($chr(35),%item) | goto error }
var %quote $readini(%file,%chan,%item)
msg %chan $+($chr(35),%item) :: %quote
}
else {
var %item 1
while (%item <= %items) {
var %quote $readini(%file,%chan,%item)
if ($1- isin %quote) {
msg %chan $+($chr(35),%item) :: %quote
}
inc %item
}
}
}
if (%!error) halt
:error
msg %chan %error
halt
}