Select a random nick popup, custom identifier & bot command

By Conscious on Jan 02, 2011

My random nick selector code.

Commands:
Identifier use by itself is $randnick (selects one) or $randnick(number under 50) selects the number of random nicks.

Bot command: !rand or !rand (up to 50)

Popup in there also.
Added flood protection after posting

Feel free to edit in any way or add colours.

alias randnick {
  if ($me !ison $chan) { echo -s 2Error: Not on chan. }
  else {
    if (!$1) {
      var %a 1
      var %b $nick($chan,$rand(1,$nick($chan,0)))
      return %b
      halt
    }
    else if ($1) {
      if ($1 == 0) { echo -a Here's your 0 selected random nicks!;) }
      if ($1 !isnum) { echo 4 Error - please change " $+ $1- $+ " into numbers or get rid of " $+ $1 $+ " to revert back to the default of 1. | halt }
      elseif ($2-) { echo 4 Please get rid of the $2- $+ !
        halt 
      }
      elseif ($1 >= 50) {
        echo -a Please select a number lower than 50.
        halt
      }
      else {
        set %1 1
        unset %b3
        while (%1 <= $1) {
          set %b2 $nick($chan,$rand(1,$nick($chan,0)))
          echo -s %b2
          var %b3old = %b3
          var %b3 = %b3old %b2
          inc %1
        }
        return %b3 
      }
    }
  }
}

menu channel {
  Random Nicks:
  .Over Ten 
  ..Say: {
    var %no $$?="How many random nicks to be selected?"
    msg $chan %no random $iif(%no > 1,nicks,nick) in $chan $+ : $randnick(%no)
  }
  ..Echo: {
    var %no $$?="How many random nicks to be selected?"
    echo -a %no random $iif(%no > 1,nicks,nick) in $chan $+ : $randnick(%no)
  }
  .One
  ..Say: msg $chan One random nick in $chan $+ : $randnick
  ..Echo: echo -a One random nick in $chan $+ : $randnick
  .Two
  ..Say: msg $chan Two random nicks in $chan: $randnick(2)
  ..Echo: echo -a Two random nicks in $chan: $randnick(2)
  .Three
  ..Say: msg $chan Three random nicks in $chan $+ : $randnick(3)
  ..Echo: echo -a Three random nicks in $chan $+ : $randnick(3)
  .Four
  ..Say: msg $chan Four random nicks in $chan $+ : $randnick(4)
  ..Echo: echo -a Four random nicks in $chan $+ : $randnick(4)
  .Five
  ..Say: msg $chan Five random nicks in $chan $+ : $randnick(5)
  ..Echo: echo -a Five random nicks in $chan $+ : $randnick(5)
  .Six
  ..Say: msg $chan Six random nicks in $chan $+ : $randnick(6)
  ..Echo: echo -a Six random nicks in $chan $+ : $randnick(6)
  .Seven
  ..Say: msg $chan Seven random nicks in $chan $+ : $randnick(7)
  ..Echo: echo -a Seven random nicks in $chan $+ : $randnick(7)
  .Eight
  ..Say: msg $chan Eight random nicks in $chan $+ : $randnick(8)
  ..Echo: echo -a Eight random nicks in $chan $+ : $randnick(8)
  .Nine
  ..Say: msg $chan Nine random nicks in $chan $+ : $randnick(9)
  ..Echo: echo -a Nine random nicks in $chan $+ : $randnick(9)
  .Ten
  ..Say: msg $chan Ten random nicks in $chan $+ : $randnick(10)
  ..Echo: echo -a Ten random nicks in $chan $+ : $randnick(10)
  .Cancel: halt
}

on *:TEXT:!rand*:#: {
  if (%floody != on) {
    if (!$2) { msg $chan Random nick in $chan $+ : $randnick 
      set -u5 %floody on
    }
    else if ($2) {
      if ($2 >= 50) {
        msg $chan Please select a lower number!
      }
      if (!$3) {
        msg $chan Random $iif($2 > 1,nicks,nick) in $chan $+ : $randnick($2) 
        set -u5 %floody on
      }
      elseif ($3) { msg $chan Please use the correct command "!rand <number> or !rand". }
    }
  }
}

Comments

Sign in to comment.
Conscious   -  Jan 03, 2011

Yes, left intentionally like that. It can be easily modified if someone doesn't want it like that

 Respond  
Jethro   -  Jan 02, 2011

So the client that runs the code gets randomized too?

 Respond  
Conscious   -  Jan 02, 2011

Added an $iif to remove nick/s to make it say nick or nicks.

 Respond  
Conscious   -  Jan 02, 2011

Fix small grammar issues.

 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.