Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.26 KB | None | 0 0
  1. sub on_mode {
  2. # mostly you can ignore all text between here
  3. # ----------------------------------------------------------------------------
  4.   my ($kernel, $modewho, $modewhere, $mode, $modesuffix1, $modesuffix2, $modesuffix3, $modesuffix4) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6];
  5.   my $modenick    = (split /!/, $modewho)[0];
  6.   my $ts      = scalar localtime;
  7.   my $modesuffixes = "";
  8.   %modelist = ();
  9.   if ($modesuffix1 ne "") {
  10.     $modesuffixes = " " . $modesuffix1;
  11.     if ($modesuffix2 ne "") {
  12.       $modesuffixes = $modesuffixes . " " . $modesuffix2;
  13.       if ($modesuffix3 ne "") {
  14.         $modesuffixes = $modesuffixes . " " . $modesuffix3;
  15.         if ($modesuffix4 ne "") {
  16.           $modesuffixes = $modesuffixes . " " . $modesuffix4;
  17.     }
  18.       }
  19.     }
  20.   }
  21.   @modearray = split(//, $mode);
  22.   $actualmodenum = 0;
  23.   $modenum = 0;
  24.   foreach $modeloop (@modearray) {
  25.     if ($modeloop =~ m/(\+|\-)/) {
  26.       $currentmodechar = $1;
  27.     }
  28.     else {
  29.       $actualmodenum = $actualmodenum + 1;
  30.       if ($modeloop =~ m/(o|v|b|f|e|I|j|l|k|q)/) {
  31.         $modenum = $modenum + 1;
  32.     if ($modenum == 1) {
  33.       $modeparaloop = $modesuffix1;
  34.     }
  35.     elsif ($modenum == 2) {
  36.       $modeparaloop = $modesuffix2;
  37.     }
  38.     elsif ($modenum == 3) {
  39.       $modeparaloop = $modesuffix3;
  40.     }
  41.     elsif ($modenum == 4) {
  42.       $modeparaloop = $modesuffix4;
  43.     }
  44.     $modelist{$actualmodenum} = $currentmodechar . $modeloop . " " . $modeparaloop;
  45.       }
  46.       else {
  47.         $modelist{$actualmodenum} = $currentmodechar . $modeloop;
  48.       }
  49.     }
  50.   }
  51. # ----------------------------------------------------------------------------
  52. # and here
  53.   while (($key, $value) = each %modelist) {
  54. # $value now equals something like this: +q *!*@lol   or perhaps: +o nick   or perhaps +m   or perhaps -b *!*@hi   Because you can
  55. # set multiple modes in one line, we use a while loop to go through this. The code above organizes the modes into the %modelist
  56. # hash, which is easy to use. The code below should make the bot to reop itself it it's been deopped. Use it as a reference.
  57. # ( if the code doesn't work, convert it to regex, e.g.: if ($value =~ m/\-o\s+$mynick/) { reclaim op here} )
  58.     if ($value eq "-o $mynick") {
  59.       $irc->yield(privmsg => ChanServ => "op $modewhere" );
  60.     }
  61.   }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement