Clone Detection

Platform:  mIRC
Published  Feb 19, 2011
Updated  Feb 20, 2011
Yes, I realize it's a common snippet but I decided to do some brushing up on mIRC today and it's what came to mind, so enjoy. :D

I had originally coded it to work in conjunction with the "Join" event, but I decided to add Text event support providing some conformity for the various needs.

-Functions-
- $clone(#Channel,Host/Wildcard).join -- Scans the channel specified for any matching hosts and lists the nicks with the matching hosts.
- $clone(#channel).text -- Scans the entire channel for any duplicate hosts and lists them according to Address and nicks that address is associated with.

Obviously I named the alias properties after the event it works best with but feel free to alter it how you will to fit your needs. PLEASE NOTE: It will not work without an attached property. (EX. $clone(#) will render no response.) on !*:JOIN:#:{ /noop $clone(#,$address($nick,2)).join } }
alias clone {
goto $iif($istok(join text,$prop,32),$prop)
:join
if ($ialchan($2,$1,0) > 1) {
var %a = 1,%c = $v1
while (%a <= %c) {
var %b %b $gettok($ialchan($2,$1,%a),1,33)
inc %a
}
.timer 1 0 echo -t $1 06[Clone] Address:( $+ $2 $+ ) Nicks:( $+ $replace(%b,$chr(32),$+($chr(44),$chr(32))) $+ )
halt
}
:text
var %a = 1,%b = 1,%d = 0
while (%a <= $nick($1,0) && !$findtok(%c,$nick($1,%a),1,32)) {
inc %d
if ($ialchan($address($nick($1,%a),2),$1,0) > 1) {
while (%b <= $ialchan($address($nick($1,%a),2),$1,0)) {
hadd -m Clone %d $hget(Clone,%d) $gettok($ialchan($address($nick($1,%a),2),$1,%b),1,33)
inc %b
}
}
if ($hget(Clone,%d)) { msg $chan 06[Clone] Address:( $+ $address($gettok($hget(Clone,%d),1,32),2) $+ ) Nicks:( $+ $replace($hget(Clone,%d),$chr(32),$+($chr(44),$chr(32))) $+ ) | hfree Clone }
inc %a
}
}

Comments

Sign in to comment.
DFSFOT   -  Jan 18, 2012
can you also make this manually?
so when you type in an alias. that it check all current users and look for clones?
 Respond  
SunnyD   -  Nov 17, 2011
@Person You raise a valid point. Replacing 'msg $chan' and 'echo -t $1' with 'return' should allow you to control where the data goes instead of having a predetermined output setting.
 Respond  
Person   -  Jun 10, 2011
Would've been nicer if the Clone info wasnt posted out in the chatroom for everyone to see x.x
 Respond  
SunnyD   -  Feb 20, 2011
Alright, did some updating. There's still 2 routines ;] but I used a goto command that functions in the same manner. Removed the timer initiating the $clone() and some reliability upon the variables by using the already used hash tables.

Thanks all for the feedback. :P
 Respond  
MoshMage   -  Feb 20, 2011
Sweetly small! If i did care about clones i'd use this myself (against having to code something to do this). Nice one :)
 Respond  
SnoooP   -  Feb 20, 2011
Nice work SunnyD, I've been after a clone snippet, I just forgot to get one, this reminded me :P +like
 Respond  
jaytea   -  Feb 20, 2011
the problem you describe occurs when mIRC hasn't yet updated the nicklist or IAL, in which case the user who just joined wouldn't be included in $ialchan($wildsite, #, 0). however, this updating happens before on JOIN is triggered (with or without the ^ prefix) so you can be quite sure clone alias will successfully find them. after all, the first timer in your current version of the code effectively does nothing, and you've observed that your code works properly right? :P in cases where your results are actually off by 1 (this happens in on PART, for example), /updatenl can be used to update the nicklist and IAL immediately.

as for delaying the echoes to accommodate a greet, that's certainly a good consideration, but is it the most sensible one; might it not be more appropriate to forgo the timer and display the clone echo just under the join message? alerting the presence of clones is more closely associated with the single act of them joining the channel rather than a join+msg combination.
 Respond  
Jethro   -  Feb 20, 2011
All that aside, SunnyD, you really don't need two properties when one will do it all. You save about 200+ bytes too.
 Respond  
SunnyD   -  Feb 20, 2011
I used the timers because when i was testing it wasn't catching all the clones. it would evaluate the number of clones at 3 then promptly switch to 2 leaving out a clone. I'm off mIRC for today, but I'll scope out some improvements tomorrow. Also The timers were there for delayed output so it wouldn't get mixed in with someone who has a greet; admittingly probably not necessary on input but more for output. As for the 'noop' command, it was dropping invalid parameters since the timer was invoking an identifier instead of a true command and it was a way to soothe the error.
 Respond  
Jethro   -  Feb 20, 2011
Thanks much again jaytea for your thoughtful explanation to what I have overlooked.
 Respond  
jaytea   -  Feb 19, 2011
just to clear up some of what's been mentioned, what you currently have:

Code

 


will evaluate $clone() immediately, within the context of the join event, then set up a timer whose command includes the return value of $clone(), ie:

Quote


* Timer 1 1 time(s) 1ms delay noop <value of $clone(#,$address($nick,2)).join>


since $clone() doesn't return anything at all, what you have there is equivalent to:

Code

 


there's very little point in having those 0-delay timers - and none at all in naming them, as someone mentioned - since you're not using anything in those timers that cannot be called directly from the event or alias, nor modifying the order of interpretation of those commands in any significant way. in fact, using timers willy nilly like that can, in some cases, leave your code open to being exploited :P

the reason this didn't work:

Code

 


is that '$!clone(#,$wildsite).join' evaluates to produce '$clone(#,$wildsite).join' which cannot evaluate properly within the context of the timer, since # and $wildsite aren't passed to the timer. standard procedure is to space out those parts to allow them to evaluate initially:

Code

 


but again, this leaves your code open to potential problems, eg. if the channel name contains an unbalanced ')'.
 Respond  
blackvenomm666   -  Feb 19, 2011
i agree with napa sunny. nice job likes
 Respond  
Jethro   -  Feb 19, 2011
Ouch my bad. Using ! will render it unresponsive. I've further tested your code and realized you could've just used one routine instead of two:

Code

 
And hfree the hash table so it starts anew for the next session.
 Respond  
napa182   -  Feb 19, 2011
One thing as well SunnyD, you may want to name your timers.
Also nice lil snippet.. 7/10 +like
 Respond  
SunnyD   -  Feb 19, 2011
Fixed, thanks all.
 Respond  
Jethro   -  Feb 19, 2011

Quote

.timer 1 0 $!clone(#,$wildsite).join
should resolve this error.
 Respond  
SunnyD   -  Feb 19, 2011
Will do, thanks. :)

EDIT: I'll look into it again Dean, although i can't seem to come across it. :/ Can you provide more details as to what your inputting when you get the error?
 Respond  
_Dean_   -  Feb 19, 2011
the original code, still returning

Quote


* /timer: insufficient parameters
 Respond  
Jethro   -  Feb 19, 2011
You can replace the join event with this one:

Code

 
and keep the rest intact.

Nice, neat work.
 Respond  
SunnyD   -  Feb 19, 2011
Touched it up a little bit and seems to be working fine with any wildcards/addresses supplied.
 Respond  
Jethro   -  Feb 19, 2011
SunnyD, $address($nick,2) is the same as $wildsite

The only difference is that it's shorter than $address($nick,2)

_Dean_'s example will return it as a type 2 address with the exception of the @ symbol.

 Respond  
Jethro   -  Feb 19, 2011
No competition but as a suggestion: why'd you use $+(*!*,$site) when you could simply use $wildsite
 Respond  
SunnyD   -  Feb 19, 2011
I'll check it out. Never really bothered using your combination $+(*!*,$site) seeing as its the same as $address($nick,2) although shorter it is.

EDIT: How exactly are you testing $site? Obviously it will return an error if triggered outside an event seeing as theres nothing for it to grab
 Respond  
_Dean_   -  Feb 19, 2011

Code

 


Code

 


the identifier $site will return all hostmask after the @ the, by the way, i tested the original one, and its returning

Quote


* /timer: insufficient parameters
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.