Originally Posted By: Wims
[quote]
In the meantime, you can check if $2 starts with a '!' by using for example if (!* iswm $2) or if ($left($2,1) == !)


thank you wims, but im not sure where to put that? i played around with it for a while yesterday, but couldnt get it to work right...

i am hoping to get a proofread and some help with simplfying the code if necesarry and adding security to it at this point.

this is my current code:
Code:
   elseif ($1 == !delcmd) && (!$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 exist. | halt }


my new issues are:
1. doesnt check properly and notify if !delcmd <trigger> does not exist I got this working finally. moved elseif statement for checking to a new elseif and created a new $1 $2 check for non existant seperate from the check for existing
2. could not figure out how to implement the quoted snippet into my code yet to check for ! prefix before deletion

To-Do:
1. secure my code as mentioned by wims smile
2. get !editcmd snippet to work.

sorry, im still kinda new to scripting in mirc, thank you for your patience with me.

here is the whole code im trying to simplify and secure at this point. again, thanks for the tip on that one wims. i didnt even realize there was a security issue involved.
Code:
on *:TEXT:*:*: {
  if ($1 == !addcmd) { 
    if (!$2) { msg $chan $nick More parameters needed. | halt }
    elseif ($2 == !addcmd) || ($2 == !delcmd)  || ($2 == ! $+ $null) { msg $chan $nick Primary triggers cant be set. | halt }
    elseif (!$2 = !$read(scripts/cc.txt,ntw,* $+ $2 $+ *)) { msg $chan $2 already taken. | 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 -il8 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 == !delcmd) && (!$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 exist. | 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
  }
}

Last edited by bandbonjtv; 15/10/12 12:04 AM. Reason: (delete issue solved) found a way to delete with check for existing triggers and respond if the trigger does not exist