0

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..

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 $+ )
}

From this script.. i am using a matching code to see if a nick is on this file and this works fine

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

now.. this is what i need to get changed which i can't do.. atm.. i am looking on the txt tile for a matching nick which is always specified by $4... but.. I want the script to message the channel the nick - reason FROM the txt file instead.. where atm it just says connected watched nick - $4 (nick)

The txt file contains nick reason on seperate lines like this

gary troublemaker 
radomly testuser 
julie needs help with channel

can i have an edit please so that the script outputs the information on the matched nick "and" the reason from the txt file please

1 Answers1

0

$read() with the s switch returns the text after the matched word, as per the documentation:

//echo $read(info.txt, s, mirc)
Scans the file info.txt for a line beginning with the word mirc and returns the text following the match value.

You can use $read() in conjunction with $readn, which returns the line number if a match is found, and do something like this:

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

This will grab the nick and the reason and output

Connected Watched julie - needs help with channel

when searching for julie.

M. A.
  • 415
  • 3
  • 12
  • Had to swap the $1 to $4 on the first var but the script now picks up the right info and publishes it to channel! I initially got an error till i realised i had used $txt and not the actual file location (OOOPS!!!!!) lol ... Huge thanks for the reply @M.A. – Ogion Aihal Aug 06 '21 at 19:40
  • Whoops, forgot to change $1 to $4 when posting, it was pretty much a leftover from when I was testing the script. Glad it works, you're welcome! – M. A. Aug 08 '21 at 00:03
  • It's been a huge help for sure! Although i am not too sure i will be doing another odd variant script again.. blacklists should be kept to channel join level lmao.. not unique on connect events ! – Ogion Aihal Aug 09 '21 at 08:33