UPDATE*i updated the code below to reflect my fidgeting. i finally got the
!delcmd to delete and check properly, i think i got the
!addcmd to check for the ! prefix now, but i cant get it to stop adding multiples still??? ive been fiddlin around with the code, and i think thats all thats left for debugging before moving onto securing the code and also fixing the
!editcmd section
final goal: the function of this script should add custom triggers to 3 files plus a backup file with date created blah blah, and check to see if there are duplicates before adding a new trigger thru the use of
!addcmd <!trigger> the second part of this script deletes the
<!trigger> found in the trigger list.
(ops only) the
!editcmd <!trigger> is not being messed with yet, because id like the !addcmd and !delcmd to work first before i mess with this to also get the right syntax for reading and writing parameters for the code.
the
!search <!trigger> is suppose to search the associated .txt file and return in chat all found matching wildcarded
<!triggers> (i dont want it showing triggers that dont include the ! prefix. but it can search for words without the ! prefix (there shouldnt be any wrong syntax triggers as detected by
!addcmd <!trigger> previously in the script ) i want it to say "no matches found if no results." if not right now its fine. this command is not as important as
!addcmd .
please help if you dare to take this project on
im newish to mirc scripts, but i managed to get this far on a few basic base scripts and alot of google searches.
on *:TEXT:*:*: {
if ($1 == !addcmd) && (!* iswmcs $2) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) {
elseif (!$2) { msg $chan $nick More parameters needed. | halt }
elseif ($2 == !addcmd) || ($2 == !delcmd) || ($2 == ! $+ $null) { msg $chan $nick Primary triggers cant be set. | halt }
write -il1 scripts/cc.mrc on *:TEXT: $+ $2 $+ : $+ $chr(35) $+ : { describe $chr(35) $3- } | write scripts/cc.txt $2 $3- | write scripts/cc1.txt $2 $3- $chr(91) $+ CREATED BY $+ $chr(93) $nick | /write -l4 scripts/cc.html This page was modified on: $date(ddd mmm dd $+ $chr(44) yyyy) $chr(64) $time(h:nntt) <br><ol> | write -il7 scripts/cc.html <tr><td $+ $chr(32) $+ nowrap $+ $chr(61) $+ $chr(34) $+ nowrap $+ $chr(34) $+ > $+ $chr(32) $+ $2 $+ $chr(32) $+ </td> <td> $3- </td></tr> | run -ns: scripts/ccftpbatch.bat
.timer 1 1 describe # $nick added $2 to $me $+ . Thank you for your addition. Click http://tinyurl.com/all-bot-commands for the complete list of commands.
.timer 1 1 load -rs scripts/cc.mrc | .timer 1 1 load -rs scripts/cc.txt | .timer 1 1 load -rs scripts/cc.html
}
elseif ($1 == !addcmd) && (!* iswmcs $2) && (!$2 = !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger already exists 1. | halt }
elseif ($1 == !addcmd) && (!* iswmcs $2) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger already exists 2. | halt }
elseif ($1 == !addcmd) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick wrong syntax. | halt }
elseif ($1 == !delcmd) && (!* iswmcs $2) && (!$2 = !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) {
set %delmrc on *:TEXT: $+ $2 $+ : $+
elseif ($nick !isop $chan) { msg $chan $nick not enough access. | halt }
elseif (!$2) { msg $chan $nick More parameters needed. | halt }
write -dw" %delmrc $+ *" scripts/cc.mrc
write -dw"* $+ > $2 < $+ *" scripts/cc.html
write -ds" $+ $2 $+ " scripts/cc.txt
run -ns: scripts/ccftpbatch.bat
msg $chan The trigger $2 has been removed...hopefuly?
.timer 1 1 load -rs scripts/cc.mrc | .timer 1 1 load -rs scripts/cc.txt | .timer 1 1 load -rs scripts/cc.html
unset %delmrc
}
elseif ($1 == !delcmd) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger doesnt exists. | halt }
elseif ($1 == !delcmd) && (!$2 = !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger doesnt exists. | halt }
elseif ($1 == !editcmd) {
set %istriggeredit $2
set %istriggert $3 $4-
if ($nick !isop $chan) { msg $chan $nick not enough access. | halt }
elseif (!$3) { msg $chan $nick More parameters needed. | halt }
elseif (!$read(scripts/cc.txt,ntw,* $+ %istriggeredit $+ *)) { msg $chan $nick This trigger doesnt exist. | halt }
write -ds" $+ %istriggeredit $+ " scripts/cc.txt | write scripts/cc.txt %istriggert
msg $chan The trigger %istriggeredit has been edited...hopefuly? | run -ns: scripts/ccftpbatch.bat
unset %istriggeredit
unset %istriggert
}
elseif ($1 == !search) {
set %istriggersearch $2
elseif (!$3) { msg $chan not the correct parameters | halt }
elseif (!$read(scripts/cc.txt,nts,* $+ %istriggersearch $+ *)) { msg $chan $nick This trigger doesnt exist. | halt }
msg $chan searching %istriggersearch
filter -ff scripts/cc.txt scripts/temp.txt * $+ %istriggersearch $+ *
.play -pq3f1m1 $chan scripts/temp.txt 2000
remove scripts/temp.txt
unset %istriggersearch
}
}