tglogo.png
0 LIKES

Snippet


Putmode by simo

In Category General IRC Posted by Snippets On 12/04/23
Tags: putmode simo myggan 

i have decided to share it here as it has dissapeared from the net totally and cant be found anywhere

Author is myggan:
putmode 1.2 by myggan

this fine code is very usefull to compress modes in the form of like : +bbbbbbbbbbbbRml 120 instead of 1 mode setting per command
so basically if u send a bunch of modes to it, it compresses it and sends out as stacked modes as much as the ircds supports per line making it less spammy on channel if u would have to set a lot of modes in 1 go

syntax:
putmode $chan +modehere
putmode $chan +l 165
putmode $chan +bbbbbbb !@host !@host1 !@host2 !@host3 !@host4 !@host5 !@host6
Alias putmode {
  if (!$isid) {
    var %echo = !echo -acq $+ $iif($active == Status Window,e) info *
    var %strict = $true
    if ($left($1,1) == -) {
      if (f isincs $1) %strict = $false
      if (t isincs $1) !.echo -q $regex(putmode,$1,/t(\d*)/)
      tokenize 32 $2-
    }
    if ($2 == $null) %echo /putmode: insufficient parameters
    elseif ($me !ison $1) %echo /putmode: you are not on $1
    elseif  (!$nick($1,$me,@&~%))  { %echo /putmode: you need to need to  be at least half-opped } 
    else {
      var %name = putmode. $+ $cid $+ . $+ $1
      if (!$timer(%name)) {
        hadd -m %name index -1
        hadd -m %name current 0
        hadd -m %name strict $iif(%strict,$true,$false)
        !.timer $+ %name -m 0 $iif($regml(putmode,1) isnum,$ifmatch,1400) putmode.exec $cid $1
        !.echo -q $regex(putmode,reset,/reset/)
      }
      hinc -m %name index
      hadd -m %name $hget(%name,index) $2-
    }
  }
}

alias putmode.exec {
  var %name = putmode. $+ $1 $+ . $+ $2, %parameter, %parameters, %tmp, $&
    %index = $hget(%name,current), %subindex, %modestring, %prefix, $&
    %parmrequired = $remove($gettok($chanmodes,1-2,44),44) $+ $nickmode, $&
    %parmrequiredset = $gettok($chanmodes,3,44), %string, %substring, %operator
  while ($hget(%name,%index) <= $hget(%name,index)) {
    %string = $ifmatch
    %subindex = 1
    while (%subindex <= $len($gettok(%string,1,32))) {
      %substring = $mid(%string,%subindex,1)
      %parameter = $gettok(%string,2,32)
      if (%substring isin +-) {
        %tmp = %prefix
        %prefix = $ifmatch
        if (%prefix == %tmp) goto loopend
      }
      elseif (%substring isincs %parmrequired || (%substring isincs %parmrequiredset && %prefix == +)) {
        if (%substring isincs $nickmode && $gettok(%string,2,32) !ison $2) goto loopend
        elseif (%substring isincs bhov && $hget(%name,strict)) {
          if (%substring === b) && ($chr(33) !isin %parameter) && (@ !isin %parameter) {
            if (%parameter == $null) !.echo -q .
            elseif (. !isin %parameter) %parameter = %parameter $+ !*@*
            else %parameter = *!*@ $+ %parameter
          }
          %operator = $iif(%prefix == -,!) $+ is $+ $replacex(%substring,b,ban,q,owner,o,op,h,hop,v,voice)
          if (%parameter %operator $2) goto loopend
        }
        %parameters = %parameters %parameter
        %string = $gettok(%string,1,32) $gettok(%string,3-,32)
      }
      %modestring = %modestring $+ %substring
      if ($numtok(%parameters,32) == $modespl) {
        if (!$nick($1,$me,@&~%)) !mode $2 %modestring %parameters
        %string = $mid($gettok(%string,1,32),$calc(%subindex + 1)) $gettok($hget(%name,%index),$calc($modespl + 2) $+ -,32)
        hadd -m %name %index $iif($left(%string,1) !isin +-,%prefix) $+ %string
        goto end
      }
      :loopend
      inc %subindex
    }
    hdel %name %index
    hinc %name current
    inc %index
  }
  if (($me ison $2 || $me ison $2) && $len(%modestring) > 1) {
    !mode $2 %modestring %parameters
    hdel %name %index
  }
  :end
  if ($hget(%name,0).item == 3) putmode.cleanup $1 $2
}

 alias putmode.cleanup {
  var %name = putmode. $+ $1 $+ . $+ $2
  !.timer $+ %name off
  hfree -w %name
}

ON *:KICK:#:if ($knick == $me) putmode.cleanup $cid $chan
ON *:PART:#:if ($nick == $me) putmode.cleanup $cid $chan
ON *:DISCONNECT:{ putmode.cleanup $cid *  | echo -at 0,4 *!*...Disconnected...*!*  00,03 $network  }


Comments 0


Please note that on our website we use cookies necessary for the functioning of our website, cookies that optimize the performance. To learn more about our cookies, how we use them and their benefits, please read our Cookie Policy.
I Understand