help me - addcmd delcmd !search

By bandbonjtv on Jan 30, 2013

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 + 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 .mrc file and return in chat all found matching wildcarded <!triggers> (i dont want it showing triggers that dont include the ! prefix. (there shouldnt be any as detected by !addcmd <!trigger> ) i want it to say "no matches found." this command is not as important as !addcmd.

please help if you dare to take this project on im newish to mirc scripting, but i managed to get this far on a basic base script starting out and alot of google searches. i asked the same question on forums.mirc also.

after i get this to work properly to avoid multiples from being added, and after it checks for the ! prefix inside $2, i will work on securing the code for exploits. untill then, id just like to see the code work. thank you

on *:TEXT:*:*: {
  if ($1 == !addcmd) && ($nick isop $chan) && (!* iswmcs $2) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { 
    elseif (!$2) { msg $chan $nick More parameters needed. | halt }
    elseif ($nick !isop $chan) { msg $chan $nick not enough access. | 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) && ($nick isop $chan) && (!* iswmcs $2) && (!$2 = !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger already exists 1. | halt }
  elseif ($1 == !addcmd) && ($nick isop $chan) && (!* iswmcs $2) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger already exists 2. | halt }
  elseif ($1 == !addcmd) && ($nick isop $chan) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick wrong syntax. | halt }

  elseif ($1 == !delcmd) && ($nick isop $chan) && (!* 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) && ($nick isop $chan) && ($2 != !$read(scripts/cc.mrc,ntw,* $+ : $+ $2 $+ : $+ *)) { msg $chan $nick This trigger doesnt exists. | halt }
  elseif ($1 == !delcmd) && ($nick isop $chan) && (!$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
  }
}

Comments

Sign in to comment.
bandbonjtv   -  Feb 02, 2013

i need help

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.