Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub on_mode {
- # mostly you can ignore all text between here
- # ----------------------------------------------------------------------------
- my ($kernel, $modewho, $modewhere, $mode, $modesuffix1, $modesuffix2, $modesuffix3, $modesuffix4) = @_[KERNEL, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6];
- my $modenick = (split /!/, $modewho)[0];
- my $ts = scalar localtime;
- my $modesuffixes = "";
- %modelist = ();
- if ($modesuffix1 ne "") {
- $modesuffixes = " " . $modesuffix1;
- if ($modesuffix2 ne "") {
- $modesuffixes = $modesuffixes . " " . $modesuffix2;
- if ($modesuffix3 ne "") {
- $modesuffixes = $modesuffixes . " " . $modesuffix3;
- if ($modesuffix4 ne "") {
- $modesuffixes = $modesuffixes . " " . $modesuffix4;
- }
- }
- }
- }
- @modearray = split(//, $mode);
- $actualmodenum = 0;
- $modenum = 0;
- foreach $modeloop (@modearray) {
- if ($modeloop =~ m/(\+|\-)/) {
- $currentmodechar = $1;
- }
- else {
- $actualmodenum = $actualmodenum + 1;
- if ($modeloop =~ m/(o|v|b|f|e|I|j|l|k|q)/) {
- $modenum = $modenum + 1;
- if ($modenum == 1) {
- $modeparaloop = $modesuffix1;
- }
- elsif ($modenum == 2) {
- $modeparaloop = $modesuffix2;
- }
- elsif ($modenum == 3) {
- $modeparaloop = $modesuffix3;
- }
- elsif ($modenum == 4) {
- $modeparaloop = $modesuffix4;
- }
- $modelist{$actualmodenum} = $currentmodechar . $modeloop . " " . $modeparaloop;
- }
- else {
- $modelist{$actualmodenum} = $currentmodechar . $modeloop;
- }
- }
- }
- # ----------------------------------------------------------------------------
- # and here
- while (($key, $value) = each %modelist) {
- # $value now equals something like this: +q *!*@lol or perhaps: +o nick or perhaps +m or perhaps -b *!*@hi Because you can
- # set multiple modes in one line, we use a while loop to go through this. The code above organizes the modes into the %modelist
- # 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.
- # ( if the code doesn't work, convert it to regex, e.g.: if ($value =~ m/\-o\s+$mynick/) { reclaim op here} )
- if ($value eq "-o $mynick") {
- $irc->yield(privmsg => ChanServ => "op $modewhere" );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement