mIRC Home    About    Download    Register    News    Help

Print Thread
#270807 03/10/22 08:44 AM
Joined: Apr 2005
Posts: 82
X
Babel fish
OP Offline
Babel fish
X
Joined: Apr 2005
Posts: 82
on *:text:*:#:{
if ($1 == flores) || ($1 == vendo flores) { /msg verdugo test # $nick $time }
}

its wright or wrong?

thnx

Joined: Jan 2004
Posts: 1,944
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 1,944
No.

Things you may want to consider:

1. Your event will do this in all channels, so you probably would want to limit to 1 or possibly more listed channels instead of the 2nd asterisk. You can also have multiple channels by listing them separated by commas but no spaces, as described in /help ON TEXT
2. Your event is sending a query message to the nick 'verdugo' without making sure that verdugo exists. One way is to check if verdugo is in this channel's nicklist, but it gets more complicated if you need to check if verdugo is on that network without being in the channel, by putting verdugo in your notify list and then checking there instead of in the nicklist.
3. While your if() statement works, i prefer to be in the habit of always having parenthesis wrapped around the entire condition, because when not doing that, there can be cases where $v1 and $v2 are not filled as expected. Plus, that makes it easier to read the code later.
4. This will react only to 'flores' but not 'vendo flores'. In the ON TEXT event, the 1st word is $1 and the 2nd word is $2, so $1 cannot be 2 words. If you want it to react to the 2 words "vendo flores", you must match that against $1-2. Or if you want to match your 1 or 2 words against the entire line then match against $1- which would prevent matching if there's any text following your triggers
5. this does not impose a throttle on the trigger, so if 100 different nicks cooperate to each type 'flores' 5 times, this causes you to send 500 query messages to verdugo at the same time. This can get verdugo mad at you, and can possibly cause either you or verdugo to be flooded off the network. To defend against that, you should use either a hashtable item or a global variable to prevent that. I prefer using a hashtable item that unsets after the time limit, because there are rare cases where the global variable does not get unset correctly, and your trigger would then be disabled forever. Another defense is to go to tools/options/irc/flood to be certain that 'enable flood protection' and 'own messages' are checked. It's a little more coding, but there are ways to have prevent the trigger from being used more often than once per 15 seconds while preventing any 1 nicks from using the trigger more often than 60 seconds

Here's another way to modify your event by making it so
  • behaves only in channel #test1
  • includes the outer parenthesis
  • makes sure that verdugo is a nick in the nicklist of whichever channel the text is seen
  • checks for the 1-word or 2-word triggers while permitting other text to follow
  • ignores the trigger if it has been used in the last 15 seconds by anyone


Code
ON *:text:*:#test1:{
  if (($1 == flores) || ($1-2 == vendo flores)) {
    if ($hget(flores,ignore)) return
    if ($nick(#,verdugo)) echo # /msg verdugo test # $nick $time
    hadd -mu15 flores ignore 1
  }
}

This reacts to
flores
vendo flores
flores anything
vendo flores anything

If you don't want to allow anything following your 2 triggers, change $1 and $1-2 to each be $1-

to react only in 2 channels, change

:#test1:
to
:#test1,#test2:

To change the ignore time from 15 seconds, change the 15 to another number in -mu5

Joined: Jul 2006
Posts: 3,960
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,960
Wrong, $1 represent a single word, the first word in this case, so it can't represent the two words "vendo flores", you can use $1-2 to represent the first two words.


Code
on *:text:*:#:{
if ($1 == flores) || ($1-2 == vendo flores) { /msg verdugo test # $nick $time }
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Wims #270813 05/10/22 12:06 AM
Joined: Apr 2005
Posts: 82
X
Babel fish
OP Offline
Babel fish
X
Joined: Apr 2005
Posts: 82
thnx for the answer!"!!! preciate


Link Copied to Clipboard