Nicklist popups

By Degausser on Feb 11, 2017

Does about the same as the default nicklist menu, but allows you to highlight multiple users and perform batch actions with one click. Probably worth removing the default script within the nicklist popups file.

This goes in the remotes section.

menu nicklist {
  !Info: uwho $$1-
  !Whois: MassCommand whois 0 $$1-
  !Query: MassCommand query 0 $$1-
  -
  !Control
  .Admin +: changeState +q $$1-
  .Admin -: changeState +q $$1-
  .Sop +: changeState +a $$1-
  .Sop -: changeState -a $$1-
  .Op +: changeState +o $$1-
  .Op -: changeState -o $$1-
  .Half Op +: changeState +h $$1-
  .Half Op -: changeState -h $$1-
  .Voice +: changeState +v $$1-
  .Voice -: changeState -v $$1-
  .-
  .Kick: kickUser -n $$1-
  .Kick (reason): kickUser -r $$1-
  .Ban
  ..Default: banUser 2 + $$1-
  ..*!user@host: banUser 0 + $$1-
  ..*!*user@host: banUser 1 + $$1-
  ..*!*@host: banUser 2 + $$1-
  ..*!*user@*.host: banUser 3 + $$1-
  ..*!*@*.host: banUser 4 + $$1-
  ..nick!user@host: banUser 5 + $$1-
  ..nick!*user@host: banUser 6 + $$1-
  ..nick!*@host: banUser 7 + $$1-
  ..nick!*user@*.host: banUser 8 + $$1-
  ..nick!*@*.host: banUser 9 + $$1-
  .Kick ban
  ..Default: kickBan -n 2 $$1-
  ..*!user@host: kickBan -n 0 $$1-
  ..*!*user@host: kickBan -n 1 $$1-
  ..*!*@host: kickBan -n 2 $$1-
  ..*!*user@*.host: kickBan -n 3 $$1-
  ..*!*@*.host: kickBan -n 4 $$1-
  ..nick!user@host: kickBan -n 5 $$1-
  ..nick!*user@host: kickBan -n 6 $$1-
  ..nick!*@host: kickBan -n 7 $$1-
  ..nick!*user@*.host: kickBan -n 8 $$1-
  ..nick!*@*.host: kickBan -n 9 $$1-
  .Kick ban (reason)
  ..Default: kickBan -r 2 $$1-
  ..*!user@host: kickBan -r 0 $$1-
  ..*!*user@host: kickBan -r 1 $$1-
  ..*!*@host: kickBan -r 2 $$1-
  ..*!*user@*.host: kickBan -r 3 $$1-
  ..*!*@*.host: kickBan -r 4 $$1-
  ..nick!user@host: kickBan -r 5 $$1-
  ..nick!*user@host: kickBan -r 6 $$1-
  ..nick!*@host: kickBan -r 7 $$1-
  ..nick!*user@*.host: kickBan -r 8 $$1-
  ..nick!*@*.host: kickBan -r 9 $$1-
  .-
  .Unban: banUser 0 - $$1-
  !CTCP
  .Ping: MassCommand ctcp ping $$1-
  .Time: MassCommand ctcp time $$1-
  .Version: MassCommand ctcp version $$1-
  !DCC
  .Send: dcc send $$1
  .Chat: massCommand dcc chat $$1-
  -
  !Insult: msg $chan Look at all the strawberry nubcakes: $$1-
}

alias -l changeState {
  var %x = 1, %users, %plus = $mid($1,1,1), %letter = $mid($1,2,1), %u, %m = $iif($modespl,$ifmatch,3)
  tokenize 32 $2-
  while (%x <= $0) {
    %u = $($+($,%x),2)
    if ($nick($active,%u,%letter) && (%plus == -)) || (!$nick($active,%u,%letter) && (%plus == +)) %users = %users %u
    if ($numtok(%users,32) == %m) {
      mode $active $+(%plus,$str(%letter,$v2)) %users
      %users = $null
    }
    inc %x
  }
  if (%users) mode $active $+(%plus,$str(%letter,$numtok(%users,32))) %users
}

alias -l kickUser {
  var %x = 1, %reason = $iif($1 == -r,$?="Reason:",$null)
  tokenize 32 $2-
  while (%x <= $0) {
    kick $active $($+($,%x),2) %reason
    inc %x
  }
}

alias -l matchAddress {
  var %x = 1, %user = $1, %chan = $2, %address = $address(%user,5), %a
  while ($ibl(%chan,%x)) {
    if ($ifmatch iswm %address) %a = %a $v1
    inc %x
  }
  return %a
}

alias -l banUser {
  var %x = 1, %num = $1, %plus = $2, %y = 1, %u, %users, %m = $iif($modespl,$ifmatch,3), %n
  tokenize 32 $3-
  while (%x <= $0) {
    %u = $($+($,%x),2)
    if (%plus == +) %users = %users $address(%u,%num)
    elseif ($matchAddress(%u,$active)) %users = %users $ifmatch
    while ($numtok(%users,32) >= %m) {
      %n = $iif($v1 >= %m,%m,$v1)
      mode $active $+(%plus,$str(b,%n)) $gettok(%users,$+(1-,%n),32)
      %users = $gettok(%users,$+($calc(%n + 1),-),32)
    }
    %y = 1
    inc %x
  }
  if (%users) mode $active $+(%plus,$str(b,$numtok(%users,32))) %users
}

alias -l kickBan {
  banUser $2 + $3-
  kickUser $1 $3-
}

alias -l massCommand {
  var %x = 1, %n = $numtok($3-,32)
  while (%x <= %n) {
    $1 $iif($1 == dcc,$2,$null) $gettok($3-,%x,32) $iif($2 && $2 != dcc,$2,$null)
    inc %x
  }
}

Comments

Sign in to comment.
gooshie   -  Feb 13, 2017

You may want to have a if/else for $modespl
if a server does not report it; although I've
never seen a server not report it.
Of all those $address(0-9), not all are useful.
Also does mass ban with $address(user,2)
I actually have it named MassMode.

alias changeState {
  var %i 1,%g,%n $2-,%s $left($1,1),%m $mid($1,2,1)
  if %m = b {
    %n = ""
    while $gettok($2-,%i,32) {
      %n = %n $address($v1,2)
      inc %i
    }
  }
  while %n {
    %g = $gettok(%n,1- $+ $modespl,32)
    mode # $+(%s,$str(%m,$numtok(%g,32))) %g
    %n = $gettok(%n,$calc($modespl +1) $+ -,32)
  }
}
Degausser  -  Feb 13, 2017

Thanks, I've updated it to work with $modespl - Don't understand why you pasted that function though?

gooshie  -  Feb 15, 2017

It does everything your changeState does and can also mass ban.

Degausser  -  Feb 15, 2017

It would be pretty simple to add an additional parameter to the changeState() function in order to catch the ban number or extract ban masks from nicknames (which is why i don't understand why an example was necessary), but i opted to separate logic handling nicknames and ban masks. 2 is the most common mask, but the point of this little script is convenience, and it's not convenient to leave out options. It's not always necessary to squish everything into one function either.

Also, your function would only remove bans if they match the user based on $address(nick,2) - Whether you wanted ban mask 2 to be your sole method of banning or not, you aren't taking into account bans set by other people. Maybe it slipped your mind trying to cram so much into one function? :P

In terms of improvement, the most significant additions would probably be making sure the ibl is up to date before attempting to remove bans, and the efficiency of matchAddress() in relation to a group of nicknames - neither of which are incredibly urgent, but substantial enough for a small update.

gooshie  -  Feb 15, 2017

If I was banning individuals I'd use a reason and do it solo.
The only reason I would be mass-unbanning is if I made
a mistake while mass-banning lots of zombies.
The almost never times I would need another mask I would
probably just do it manually and if I kept having to do it
then I'd create something for that or extend the script.
Mostly it's an example. I cannot see why anyone would
use ban mask 5-9 or 0,1,3 for that matter. If your making
a plea for options then why did you leave out ban mask 10-19?
d;-P
Now, explain how ANYONE is going to remember
which ban mask #number to use in that popup.
At the very least do something like:
.Ban
..Ban mask *!user@host: banUser 0 + $$1-

It's not just about writing code it's knowing why and how it will be used.

Degausser  -  Feb 15, 2017

Fair enough, i've added a "default" ban, which also covers ban mask 2, and i've removed ban indexes and instead listed ban masks. I still think the inclusion of different masks is important, as it's better to have an option you never use, than lack an option you'd like to use.

gooshie  -  Feb 15, 2017

Well, the only other ban mask needed would be 4. Most of those other options exist for other uses like adding to users list where they can still fall flat since you have to do your own authentication check, since most people have a dynamic IP addy and the best you can do is: Nick!user@*
Something that can easily be spoofed under certain situations.

Sign in to comment

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.