mIRC Homepage

$address not working correctly

Posted By: Varadin

$address not working correctly - 26/09/14 02:29 PM

Hello,

This is one of the handy aliases I wrote for myself, directly copied from the file. The comment says pretty well what it does. More explanataions after the code...

Code:
/*
* KICKBAN selected users from the userlist
* in the active channel window, with optional reason,
* taking care of webchat users,
* collecting upto four channel modes in a single line,
* and de-opping chanops
*
*/
alias kbchan {
  if (($me !isop #) && ($me !ishop #)) {
    return
  }

  var %snick = $snick(#, 0)
  var %banstr
  var %cmdstr
  var %sign
  var %fix

  while (%snick > 0) {
    if (%fix != $null) {
      %cmdstr = +b
      %banstr = %fix
      %sign = +
    }

    ; Deop if opped
    if ($snick(#, %snick) isop #) {
      %cmdstr = %cmdstr $+ -o
      %banstr = %banstr $snick(#, %snick)
      if (%sign != -) { %sign = - }
    }
    elseif ($snick(#, %snick) ishop #) {
      %cmdstr = %cmdstr $+ -h
      %banstr = %banstr $snick(#, %snick)
      if (%sign != -) { %sign = - }
    }

    ; Ban
    if (html.chat isin $address($snick(#, %snick), 4)) {
      %fix = $remove($address($snick(#, %snick), 3), .html.chat)
    }
    elseif (mibbit.com isin $address($snick(#, %snick), 4)) {
      %fix = $remove($address($snick(#, %snick), 3), .mibbit.com)
    }
    else {
      %fix = $address($snick(#, %snick), 2)
    }

    if ($len($remove(%cmdstr,+,-)) < 4) {
      if (%sign != +) {
        %cmdstr = %cmdstr $+ +
        %sign = +
      }
      %cmdstr = %cmdstr $+ b
      %banstr = %banstr %fix
      %fix = $null
    }

    dec %snick
    if (($len($remove(%cmdstr,+,-)) < 4) && (%snick > 0)) {
      continue
    }

    mode # %cmdstr %banstr

    %cmdstr = $null
    %banstr = $null
    %sign = $null
  }
  if (%fix != $null) {
    mode # +b %fix
  }

  ; Kick
  %snick = $snick(#, 0)
  while (%snick > 0) {
    kick # $snick(#, %snick) $1-
    dec %snick
  }
}



The issue is that sometimes $address does not return the value it should - it returns nothing. Checkpoint used with the %fix variable shows sometimes it is empty. Sometimes it isn't. I've had similar issues with $address in other, simpler aliases. Here is an example output of kickban-ing three nicknames, two of which chanops. The first time (16:14) the alias fails and the server treats the command by putting nick!*@* banmasks because the corresponding parameter for (some of) the +b modes is missing.
The second time (16:16) the same alias in the same situation works just fine, as it does most of the time:

|16:14:02| * Varadin sets mode: +bb HEX!*@* Dev!*@*
|16:14:02| * Varadin sets mode: +b *!*@0xDEADBEAF.0xFF
|16:14:02| * SeenServ was kicked by Varadin (test)
|16:14:02| * HEX was kicked by Varadin (test)
|16:14:02| * Dev was kicked by Varadin (test)
|16:16:40| * Varadin sets mode: +b-o+b-o *!*@services.bg HEX *!*@imagine.dragons Dev
|16:16:40| * Varadin sets mode: +b *!*@0xDEADBEAF.0xFF
|16:16:40| * SeenServ was kicked by Varadin (test)
|16:16:40| * HEX was kicked by Varadin (test)
|16:16:40| * Dev was kicked by Varadin (test)

Tested on mIRC 6.35 and mIRC 7.32
Posted By: westor

Re: $address not working correctly - 26/09/14 03:53 PM

Try to do /who #chan before you run the alias.

/help /who
or
/help ial
Posted By: Varadin

Re: $address not working correctly - 26/09/14 06:05 PM

Thanks for the input. The thing is, it shouldn't be needed to do "/who", since the user address is supposed to already be in the internal address list...?
Quote:

A user's address is added to the list either when they join the channel, send a message to a channel, or make a mode change.

A user's address is removed from the list when they are no longer on any of the channels which you are currently on.

Posted By: westor

Re: $address not working correctly - 26/09/14 06:21 PM

Try the /who #channel maybe will solve your problem, if not then the problem is somewhere else.
Posted By: Varadin

Re: $address not working correctly - 26/09/14 06:34 PM

Yes, it solves the issue. I was commenting on that. So, mIRC does not perform /who #channel internally when I join a channel? Hm!
Posted By: Khaled

Re: $address not working correctly - 26/09/14 06:42 PM

mIRC does not perform a /who #channel when you join a channel as IRC networks will often disconnect clients that perform commands that exceed a client's sendq (the maximum amount of data that is allowed to be pending out on connection). Each IRC network has its own sendq limits. This means that a scripter should only issue a /who #channel if it is needed. A /who #channel is the only way to ensure that the IAL is filled for a particular channel. For a large channel, you may need to create a script that fills the IAL slowly or that fills it when it is empty for a particular user.
Posted By: Varadin

Re: $address not working correctly - 26/09/14 07:01 PM

Thanks for clearing that up. I thought mIRC does it internally in small steps on each /join, so at first I was more inclined to think I've encountered a bug. Having this in mind, I'll implement the script to first check IAL.

© 2020 mIRC Discussion Forums