mIRC Homepage

$read with txt and nick with particular characters

Posted By: Robertus

$read with txt and nick with particular characters - 21/02/09 05:09 PM

Hi everybody

i have a little problem

i use this script for notice me when a person write my nick in a channel.

Code:
on *:text:*:#:{
  if ($me isin $1-) && ($chan !== $active) && ($nick != $read(Ti.Cercano.txt, r, $nick)) { //echo  -a $timestamp [10iNFO]8 $nick 10su11 $chan 10sta dicendo: 1211 $left($$1-,77) $+ ... 12   } 
}
on *:action:*:#:{
  if ($me isin $1-) && ($chan !== $active) { //echo  -a $timestamp 10[10T10i 10H10a 10C10ercato8 $nick 10s10u 11 $chan $+ 10] 10s10ta 10d10icendo: $left($$1-,77) $+ ... 12   }
}
on *:notice:*:#:{
  if ($me isin $1-) && ($chan !== $active) { //echo  -a $timestamp 10[10T10i 10H10a 10C10ercato8 $nick 10s10u 11 $chan $+ 10] 10s10ta 10d10icendo: $left($$1-,77) $+ ... 12   }
}


the problem is that some nicks in Ti.Cercano.txt like |TEST| not work with this script, there are a solution, without use
Code:
&& ($nick != |TEST|) 
?


Thanks in advance smile
Posted By: argv0

Re: $read with txt and nick with particular characters - 21/02/09 05:40 PM

what made you use the 'r' switch in your $read? You'll find that that's the problem with nicks like that. If you read the help on $read you'll find the switch you need to use.
Posted By: Horstl

Re: $read with txt and nick with particular characters - 21/02/09 05:56 PM

At the moment you $read for a regex match (r switch): scan for the regular expression "$nick" in the text file. The char | (amongst other chars) is a "metachar" in regular expressions - it hasn't the literal meaning of a pipe.
As you compare this match against the full nickname, I assume you want to match full nicknames that shall be excluded - so you may use for example "&& (!$read(Ti.Cercano.txt,w,$nick))". If you want a different matching method - please provide an example / description smile
Posted By: Robertus

Re: $read with txt and nick with particular characters - 21/02/09 08:12 PM

Originally Posted By: Horstl
At the moment you $read for a regex match (r switch): scan for the regular expression "$nick" in the text file. The char | (amongst other chars) is a "metachar" in regular expressions - it hasn't the literal meaning of a pipe.
As you compare this match against the full nickname, I assume you want to match full nicknames that shall be excluded - so you may use for example "&& (!$read(Ti.Cercano.txt,w,$nick))". If you want a different matching method - please provide an example / description smile


whit it i have this error

(!$READ(TI.CERCANO.TXT, Unknown command

i only want that script ignore all nicks in ti.cercano.txt, if possible. thanks for the support horstl and argv0



Posted By: Horstl

Re: $read with txt and nick with particular characters - 22/02/09 07:29 AM

This code was meant to replace the condition "&& ($nick != $read(Ti.Cercano.txt, r, $nick))" in the line of your code that starts with:
Code:
if ($me isin $1-) && ($chan !== $active) && ($nick != $read(Ti.Cercano.txt, r, $nick)) { ....

In addition, I assumed you have the nicks-to-exclude in your textfile in the format:
Code:
nick1
anothernick
nick3
...
Is this correct?
Posted By: Robertus

Re: $read with txt and nick with particular characters - 22/02/09 07:04 PM

with this code not work nicks with | char
Posted By: Horstl

Re: $read with txt and nick with particular characters - 22/02/09 07:45 PM

I don't understand why it should fail.
Please try the following complete, modified on text event. I only changed the output a bit. Replace your current on text event with this one.
Code:
on *:text:*:#:{
  if (($me isin $1-) && ($chan != $active) && (!$read(Ti.Cercano.txt,w,$nick))) {
    echo -ta [10iNFO]08 $nick 10su11 $chan 10sta dicendo: 1211 $iif(($len($1-) <= 77),$1-,$left($1-,77) $+ ...) 12
  }
}

Posted By: RusselB

Re: $read with txt and nick with particular characters - 22/02/09 08:33 PM

It's failing, due to the fact that mIRC is evaluating the | character as a pipe (command separator).

Include the n switch with the w in the $read to prevent this.
Posted By: Horstl

Re: $read with txt and nick with particular characters - 22/02/09 08:49 PM

Without the n switch mIRC evaluates the line read - now this code does nothing with the line read but check if there's a match at all. Adding the n switch doesn't hurt (in fact it's a good habit), but it's absence won't make the code fail for nicks that contain a pipe char (or consist of a single pipe char).

Code:
//write -c test.txt $chr(124) | write test.txt abc| | echo -a $iif($read(test.txt,w,|),match) ... $iif($read(test.txt,w,abc|),match)
Posted By: argv0

Re: $read with txt and nick with particular characters - 22/02/09 09:04 PM

I don't really get it, you've completely ignored our suggestions but still claim you have a problem? Have you looked at the help and realized you were using the wrong switch? do you know which switch you should be using yet?
© 2020 mIRC Discussion Forums