mIRC Home    About    Download    Register    News    Help

Print Thread
E
Exuviax
Exuviax
E
So, I have a simple blacklist, and I am sick of using Variables. So I decided I would have it offload to a File. It had been working quite well, but is their a way I can delete words from the file?

Code:

on *:TEXT:!blacklist add*:#skyasi: {
  if ($nick isop #) {
    if ($read(skyasiblacklist.txt,nw,$3)) { msg # $nick ---> That word is already on my list. }
    msg # $nick --> " $+ $3 $+ " Has been added to my blacklist, anyone using it will be timed out for 10 minutes.
    write skyasiblacklist.txt $3
  }
  else {
    msg # $nick --> You do not have permission to add words to the blacklist.
  }
}

on *:TEXT:*:#skyasi: {
  if ($nick isop #) { return }
  if ($read(skyasiblacklist.txt,nw,$3)) {
    .timer[blacklist] 1 1 msg # .timeout $nick 600
  }
}



I basically want to be able to do !blacklist del WORD. Then it will look in the file for that word and remove it.

B
Belhifet
Belhifet
B
In a different thread we worked out this simply blacklist that uses tokens.
Code:
on *:TEXT:!blacklist add*:#: {
  if ($nick isop #) {
    set %blacklist. $+ $chan $addtok($($+(%,blacklist.,$chan),2), $3, 44)
    msg # $3 Has been added to my blacklist, anyone using $3 will be timed out for 10 minutes.
  }
  else {
    msg # Sorry $nick $+ , you do not have permission to add words to the blacklist
  }
}

on *:TEXT:!blacklist del*:#: {
  if ($nick isop #) {
    set %blacklist. $+ $chan $remtok($($+(%,blacklist.,$chan),2), $3, 44)
    msg # $3 Has been removed from the blacklist
  }
  else {
    msg # Sorry $nick $+ , you do not have permission to add words to the blacklist
  }
}

on *:TEXT:*:#: {
  if ($nick isop #) { return }
  var %i = 1
  while (%i <= $0) {
    if ($istok($($+(%,blacklist.,$chan),2), $gettok($1-,%i,32), 44) == $true)  {
      msg # $nick -> Do not use Blacklisted Words. (Timeout)
      msg # .timeout $nick 600
      break
    }
    inc %i
  }
}

If thats interesting at all to you...there ya go! if not
Code:
on *:text:!blacklist del *:#: {
  if ($nick !isop $chan) { return }
  if ($read(skyasiblacklist.txt), ns, $3)) {
    write -dl $readn skyasiblacklist.txt 
  msg $chan $2 has been removed from the blacklist.
 }


Also..It kinda looks like it only times out for blacklisted words if it is the 3rd word in a sentence...is that what you intended?

In this example
Code:
!blacklist del *

$1 = !blacklist $2= del and $3= the first word in * $3- is word number three and every word after...the rest of the line.

In this line of your code
Code:
if ($read(skyasiblacklist.txt,nw,$3))

You are checking the 3rd($3) word in the line of text to see if its in the text file.

If you notice in the example we've used
Code:
  var %i = 1
  while (%i <= $0)

$0 returns the total number of words in a line. So this is saying
Set a temporary variable(%i) and give it the value of 1. If that varible is LESS than the total number of words in the line repeat this 'WHILE' code. At the end of that code we inc %i which increases %i by 1. So the second time around %i is 2..then 3 4 5. Until %i is = $0 (total words in the line)

We tokenize the line of text $gettok($1-,%i,32)..$1- being the first word in the text, and every word after it. We request the %i token. So First we get token 1 then 2 and 3..ect as the while statement loops and %i increases. The 32 is the character that is between each token(word). Character 32 is space.

Anywho I hope this was useful.

Last edited by Belhifet; 03/08/14 08:51 AM.

Link Copied to Clipboard