mIRC Home    About    Download    Register    News    Help

Print Thread
$read with txt and nick with particular characters #209711 21/02/09 05:09 PM
Joined: Jun 2007
Posts: 9
R
Robertus Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2007
Posts: 9
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

Re: $read with txt and nick with particular characters [Re: Robertus] #209713 21/02/09 05:40 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: $read with txt and nick with particular characters [Re: Robertus] #209714 21/02/09 05:56 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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

Re: $read with txt and nick with particular characters [Re: Horstl] #209722 21/02/09 08:12 PM
Joined: Jun 2007
Posts: 9
R
Robertus Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2007
Posts: 9
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




Re: $read with txt and nick with particular characters [Re: Robertus] #209738 22/02/09 07:29 AM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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?

Re: $read with txt and nick with particular characters [Re: Horstl] #209750 22/02/09 07:04 PM
Joined: Jun 2007
Posts: 9
R
Robertus Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
R
Joined: Jun 2007
Posts: 9
with this code not work nicks with | char

Re: $read with txt and nick with particular characters [Re: Robertus] #209751 22/02/09 07:45 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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
  }
}


Re: $read with txt and nick with particular characters [Re: Horstl] #209754 22/02/09 08:33 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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.

Re: $read with txt and nick with particular characters [Re: RusselB] #209757 22/02/09 08:49 PM
Joined: Nov 2006
Posts: 1,559
H
Horstl Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
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)

Last edited by Horstl; 22/02/09 08:54 PM.
Re: $read with txt and nick with particular characters [Re: Robertus] #209758 22/02/09 09:04 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
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?


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"