Nickname Wildcard

By Freckle on Dec 13, 2007

With this script you can make it return the nickname matching your search.

Example:

someone types: !kick Freck pwned
And the script has this:

.kick $chan $nick.s($2,$chan) $3

It will return the full nickname
or return if there are too many
if ($nick.s($2,$chan) == manymatch)

or it returns there is no match
if ($nick.s($2,$chan) == nomatch

alias nick.s {
if ($isid == $false) { halt }
  unset %match
  %count = 1
  while (%count <= $nick($2,0)) {
    if (* $+ $1 $+ * iswm $nick($2,%count) && %match) { return manymatch | break | halt }
    if (* $+ $1 $+ * iswm $nick($2,%count)) { %match = $nick($2,%count) }
    inc %count
  }
  if (!%match) { return nomatch }
  if (%match) { return %match }
}

Comments

Sign in to comment.
Freckle   -  Dec 15, 2007

Ya but will it halt the loop and continue what\'s after while or will it halt the script also

 Respond  
Rebellious   -  Dec 14, 2007

Question:

if ( $+ $1 $+ iswm $nick($2,%count) && %match) { return manymatch | break | halt }

Do I need to put the halt behind the break or will the break halt the rest too?

Nope, /break will halt the loop.

 Respond  
Freckle   -  Dec 14, 2007

Else it would continue looping till the end

 Respond  
guest598594   -  Dec 14, 2007

why do u need a break or a halt?

 Respond  
Freckle   -  Dec 14, 2007

Question:

if (* $+ $1 $+ * iswm $nick($2,%count) && %match) { return manymatch | break | halt }

Do I need to put the halt behind the break or will the break halt the rest too?

 Respond  
Freckle   -  Dec 14, 2007

Ya I heard about the $fline stuff. But never got into it.

 Respond  
Rebellious   -  Dec 14, 2007

I see. It looks a bit better now, but you don\'t really need the loop. You can just use mIRC\'s $fline:

alias nick.s { 
  if ($fline($2,$+(*,$1,*),2,1)) return manymatch
  elseif ($fline($2,$+(*,$1,*),1,1)) return match
  else return nomatch
}
 Respond  
Freckle   -  Dec 14, 2007

Ya I forgot to remove the \"echo -a\"
I don\'t use /var a lot, easier for me to debug.

 Respond  
Rebellious   -  Dec 13, 2007

@the code: Instead of using %count = 1 you could use /var. Also, the process of echoing each nick through the loop is very irritating. ;)

 Respond  
guest598594   -  Dec 13, 2007

check if $isid

 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.