mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2014
Posts: 54
O
Orobas Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Oct 2014
Posts: 54
Hi Folks.. i am working on a blacklist script and so far it works fine.. I am adding a nick and reason and it saves and deletes fine..
Code
alias -l txt { return C:\Users\hifin\Desktop\mibbitnames\badnick.txt }
alias -l mychan { return #mastercontrol }

ON *:TEXT:!add *:$($mychan): {
  write $qt($txt) $2-
  msg $chan 4ADD Watched nick - $2-
}

ON *:TEXT:!del *:$($mychan): {
  write -d $qt($txt) $2-
  msg $chan 3DELETED Watched nick - $2-
}

ON *:TEXT:!viewlist:$($mychan): {
  var %t = $lines($txt)

  if (!$file($txt)) { msg $chan The file is empty! | return }

  msg $chan 6LIST Incoming PM
  msg $nick Start of file.. - (Lines: %t $+ )

  var %i = 1
  while (%i <= %t) { 
    var %r = $read($txt,n,%i)

    if (%r) { msg $nick %r }

    inc %i
  }

  msg $nick End of file. - (Size: $bytes($file($txt).size).suf $+ )
}

now.. the next part of my script checks a stripped out connect message for the nick which is always $4 against this txt file to get a match and if it does it will message the channel to say it has a match
Code
on ^*:snotice:*:{
if (Client connecting isin $1-) {
    window -nek @Connecting
    aline -hp  @Connecting 4 $+ $1- at $time on $date on $network
    msg #mastercontrol 6CONN $4 at $time and their IP is $remove($6,$chr(91),$chr(93))
    var %foundInTheList = $read(C:\Users\hifin\Desktop\mibbitnames\mibbitnick.txt, w, $4)
    if (%foundInTheList) {
      /msg #usercontrol $4 6connected  Mibbit default nick!
    }
    else {
      /msg #usercontrol $4 6Connected.
    }
    var %NaughtyList = $read(C:\Users\hifin\Desktop\mibbitnames\badnick.txt, ws, $4)
    if (%NaughtyList) {
      /msg #mastercontrol 9,1Connected Watched Nick  - $4
      splay -w C:/Users/hifin/Desktop/New_Server_Bot/mIRC/sounds/message.wav
    }
    haltdef
}
}


Which it does correctly..

What it wont do and what i do not know how to do.... is instead of saying that $4 is matched and has connected.. (Connected Watched Nick - nick)

is change the message so that it shows "Connected Watched Nick" - ( and displays the nick reason) from the text file

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Assuming your text file looks like

nick1 reason for nick1
nick2 reason for nick2
...

... then %NaughtyList contains the text you want to display.

Other things to fix with your script:

(1) The "var %t = $lines($txt)" should go below the line checking to see if the file size is zero
(2) You should always be in the habit of using the nt switches with $read except when you specifically want it to use a possibly numeric line#1 as if it's the number of lines in the file, and/or when you specifically want it to evaluate $identifiers and %variables found in the text file. Your script does not do any kind of authentication before writing to the text file. All that's needed is for someone to enter the specific channel and to type the triggering command, or for someone to trick you into typing a specific command.

If the line contains

nick1 test %password $asctime test

... then %NaughtyList will not contain %password, but would instead contain the contents of that %variable if any. It would evaluate $asctime at the moment when the $read command is executed, not containing the time when the file was written and not containing the literal word beginning with the dollar.

There are a lot of bad things that people can do to you if they can get you to write specific $identifier strings to a text file then get you to later $read that text from disk without using the 'n' switch.

If line#1 turns out to be numeric, though it wouldn't be in this case since nicks can't begin with a number, then that number would be used to limit how many lines of the text would be used. If line#1 was 10, then $read without the 't' switch would behave as if the line has only 10 lines following line#1, and would ignore everything beyond that.

(3) You're using the 'n' switch in your "!viewlist" trigger, but you're doing this inefficiently, instead of looping through an X lines text file X times and messaging the lines 1 at a time, you could instead do:

play $nick $qt($txt)

Note that this method avoids evaluating $identifiers in the displayed text. If you were not wanting to display the entire line, then the /play command couldn't be used without using its -a switch to have an alias which modifies the output before messaging it.

Joined: Oct 2014
Posts: 54
O
Orobas Offline OP
Babel fish
OP Offline
Babel fish
O
Joined: Oct 2014
Posts: 54
Hiya maroon and thanks for the reply

I have now got the script up and working without any issues now with the final cut being as follows

Code
var %NaughtyList = $read(C:\Users\hifin\Desktop\mibbitnames\badnick.txt, s, $4)
    if ($readn) {
      var %buf = $read(C:\Users\hifin\Desktop\mibbitnames\badnick.txt, $readn)
      /msg #mastercontrol 9,1Connected Watched Nick  $gettok(%buf, 1, 32) - reason - $gettok(%buf, 2-, 32)
      splay -w C:/Users/hifin/Desktop/New_Server_Bot/mIRC/sounds/message.wav
    }
    haltdef


Link Copied to Clipboard