Alright, this is pretty complicated. I am trying to get my bot to add commands in a certain format to an HTML file, which so far, is working! But, now I need him to be able to remove the line from the HTML file.

So far I have tired doing "write -dl(start of sentence) command.file" but it won't delete the line because their is more information then I can provide.

So here is the full script.

Code:

on *:TEXT:!cadd *:#:{
  set %name #
  if ($nick isop $chan) {
    var %command_file = C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.txt
    var %website_file = C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.html
    var %cmd = $mid($1,2)
    var %k = $+($network,-,$chan)

    if ($ini(%command_file,%k,$2) >= 1) {
      var %inusecadd = $rand(1,3)
      if (%inusecadd == 1) { msg # /me $nick > Command already in use.   }
      if (%inusecadd == 2) { msg # /me $nick --> Command already in use.  }
      if (%inusecadd == 3) { msg # /me $nick -> Command already in use.  } 
    }

    else {
      if (! isin $2) {
        var %incorrect $2
        var %correct $remove(%incorrect, $chr(33))
        var %wrongcadd = $rand(1,3)
        if (%wrongcadd == 1) { msg # /me $nick > Incorrect usage: Don't include "!" while setting the command " $+ $2 $+ " instead use " $+ %correct $+ " }
        if (%wrongcadd == 2) { msg # /me $nick --> Incorrect usage: Don't include "!" while setting the command " $+ $2 $+ " instead use " $+ %correct $+ " }
        if (%wrongcadd == 3) { msg # /me $nick -> Incorrect usage: Don't include "!" while setting the command " $+ $2 $+ " instead use " $+ %correct $+ " }       
      } 
      else {
        writeini %command_file %k $2 $3-
        write %website_file <tr> <td class="text-left"> ! $+ $2 </td> <td class="text-left"> $3- </td> </tr>
        var %cadd = $rand(1,3)
        if (%cadd == 1) { msg # /me $nick > The Command ! $+ $2 has been added to $right(#,-1) $+ 's command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt }
        if (%cadd == 2) { msg # /me $nick --> The Command ! $+ $2 has been added to $right(#,-1) $+ 's command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt  }
        if (%cadd == 3) { msg # /me $nick -> The Command ! $+ $2 has been added to $right(#,-1) $+ 's command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt  } 
      }
    }
  }

}
on *:TEXT:!cdel *:#:{
  var %cmd = $mid($2,2)
  if ($nick isop $chan) { 

    var %command_file = C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.txt
    var %website_file = C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.html
    var %k = $+($network,-,$chan)

    var %t = $readini(%command_file,n,%k,%cmd)

    if ($ini(%command_file,%k,$2) >= 1) {
      remini %command_file %k $2
      var %cdel = $rand(1,3)
      if (%cdel == 1) { msg # /me $nick > The command ! $+ $2 has been found in $right(#,-1) $+ 's command list and has been deleted. %t  }
      if (%cdel == 2) { msg # /me $nick --> The command ! $+ $2 has been found in $right(#,-1) $+ 's command list and has been deleted. %t }
      if (%cdel == 3) { msg # /me $nick -> The command ! $+ $2 has been found in $right(#,-1) $+ 's command list and has been deleted. %t } 
    } 
    else { 
      var %cdell = $rand(1,3)
      if (%cdell == 1) { msg # /me $nick > Sorry, command ! $+ $2 could not be found.  }
      if (%cdell == 2) { msg # /me $nick --> Sorry, command ! $+ $2 could not be found.  }
      if (%cdell == 3) { msg # /me $nick -> Sorry, command ! $+ $2 could not be found.  } 
    }
  }
}

on *:TEXT:!commands:#:{
  if ($read(C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.txt)) {
    var %clist = $rand(1,3)
    if (%clist == 1) { msg # /me $nick > Command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt   }
    if (%clist == 2) { msg # /me $nick --> Command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt  }
    if (%clist == 3) { msg # /me $nick -> Command list: http://exudev.ca/ $+ $right(#,-1) $+ /commands.txt.  } 
  }
  else {
    var %cnone = $rand(1,3)
    if (%cnone == 1) { msg # /me $nick > No commands found. Use !cadd [command] [message] to add new commands (No Brackets) }
    if (%cnone == 2) { msg # /me $nick --> No commands found. Use !cadd [command] [message] to add new commands (No Brackets)  }
    if (%cnone == 3) { msg # /me $nick -> No commands found. Use !cadd [command] [message] to add new commands (No Brackets)  }
  }
}



on $*:TEXT:m/\!.*/iS:#:{
  var %command_file = C:\Users\Randy\Documents\ExubotWebsite\ $+ $right(#,-1) $+ \commands.txt
  var %cmd = $mid($1,2)

  if ($me == $nick) {
    halt 
  }

  var %k = $+($network,-,$chan)
  var %t = $readini(%command_file,n,%k,%cmd)

  if ($len(%t)) { 
    var %command = $rand(1,3)
    if (%command == 1) { msg # /me > %t  }
    if (%command == 2) { msg # /me --> %t  }
    if (%command == 3) { msg # /me -> %t  } 
  }
}



So as you can see, when you add a command into the bot it writes it in two spots. Commands.txt and Commands.html (For the site) it writes it in like this



Which is awesome, because the site is reading it fine. Now come the trouble of removing one of those lines when the user type !cdel COMMMAND

I am not sure how I can get it to specify the exact line I want, as it is variable, and the user doesn't type in what the command says, with !cadd I have the user type in "Command" and "message" which is how it is set, but when removing the script has to find it just by "Command" which is what I am having issues with..

Thank you in advance


I do things with stuff that makes other things do stuff.