beefviper

mIRC - inc/dec

May 21st, 2020
135
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;inc-dec
  2.  
  3. ;author : beefviper
  4. ;date   : Aug 3, 2005
  5. ;version: 1.1
  6.  
  7. ;!inc #chan user value
  8. ;!dec #chan user value
  9. ;(also accepts /cs, /msg ChanServ, /msg ChanServ@Services.GameSurge.net)
  10.  
  11. ;inc - increases the user's access level on ChanServ by the given amount.
  12. ;dec - decreases the user's access level on ChanServ by the given amount.
  13.  
  14. alias incdec.main {
  15.   if ( !%incdec.inuse ) {
  16.     set %incdec.inuse 1
  17.     set %incdec.params $1-
  18.     .timer 1 60 incdec.timeout
  19.  
  20.     %incdec.params = $reptok(%incdec.params,!inc,inc,1,32)
  21.     %incdec.params = $reptok(%incdec.params,!dec,dec,1,32)
  22.     %incdec.params = $remtok(%incdec.params,/msg,1,32)
  23.     %incdec.params = $remtok(%incdec.params,/cs,1,32)
  24.     %incdec.params = $remtok(%incdec.params,ChanServ@Services.GameSurge.net,1,32)
  25.     %incdec.params = $remtok(%incdec.params,ChanServ,1,32)
  26.  
  27.     if ( $left(%incdec.params,1) == ! ) {
  28.       %incdec.params = $right(%incdec.params,$calc($len(%incdec.params) - 1 ))
  29.     }
  30.  
  31.     if ( $left(%incdec.params,1) == $chr(35) ) {
  32.       if ( $istok(%incdec.params,inc,32) ) {
  33.         %incdec.params = $remtok(%incdec.params,inc,1,32)
  34.         %incdec.params = $instok(%incdec.params,inc,1,32)
  35.       }
  36.  
  37.       elseif ( $istok(%incdec.params,dec,32) ) {
  38.         %incdec.params = $remtok(%incdec.params,dec,1,32)
  39.         %incdec.params = $instok(%incdec.params,dec,1,32)
  40.       }
  41.     }
  42.  
  43.     if ( $gettok(%incdec.params,1,32) == inc ) {
  44.       set %incdec.inc 1
  45.     }
  46.  
  47.     elseif ( $gettok(%incdec.params,1,32) == dec ) {
  48.       set %incdec.dec 1
  49.     }
  50.  
  51.     %incdec.params = $deltok(%incdec.params,1,32)
  52.     %incdec.params = $sorttok(%incdec.params,32,c)
  53.  
  54.     if ( ( $1 == /msg || $1 == /cs) && $left($gettok(%incdec.params,1,32),1) != $chr(35) ) {
  55.       echo -tac notice -ChanServ- No channel name provided.
  56.       unset %incdec.*
  57.       return
  58.     }
  59.  
  60.     if ( $numtok(%incdec.params,32) == 3 && $chr(35) isin $gettok(%incdec.params,1,32) && $gettok(%incdec.params,2,32) isnum ) {
  61.       set %incdec.chan $gettok(%incdec.params,1,32)
  62.       set %incdec.value $gettok(%incdec.params,2,32)
  63.       set %incdec.nick $gettok(%incdec.params,3,32)
  64.     }
  65.  
  66.     elseif ( $numtok(%incdec.params,32) == 2 && $chr(35) isin $gettok(%incdec.params,1,32) && $gettok(%incdec.params,2,32) !isnum ) {
  67.       set %incdec.chan $gettok(%incdec.params,1,32)
  68.       set %incdec.value 1
  69.       set %incdec.nick $gettok(%incdec.params,2,32)
  70.     }
  71.  
  72.     elseif ( $numtok(%incdec.params,32) == 2 && $gettok(%incdec.params,1,32) isnum ) {
  73.       set %incdec.chan $chan
  74.       set %incdec.value $gettok(%incdec.params,1,32)
  75.       set %incdec.nick $gettok(%incdec.params,2,32)
  76.     }
  77.  
  78.     elseif ( $numtok(%incdec.params,32) == 1 && $chr(35) !isin $gettok(%incdec.params,1,32) && $gettok(%incdec.params,1,32) !isnum ) {
  79.       set %incdec.chan $chan
  80.       set %incdec.value 1
  81.       set %incdec.nick $gettok(%incdec.params,1,32)
  82.     }
  83.  
  84.     else {
  85.       .timer 1 0 echo $color(notice) -t %incdec.chan -ChanServ- Error: Invalid params.
  86.       unset %incdec.*
  87.       return
  88.     }
  89.  
  90.     if ( %incdec.nick == $me ) {
  91.       .timer 1 0 echo $color(notice) -t %incdec.chan -ChanServ- Error: Cannot inc/dec yourself.
  92.       unset %incdec.*
  93.       return
  94.     }
  95.  
  96.     elseif ( %incdec.value < 1 || %incdec.value > 498 ) {
  97.       .timer 1 0 echo -tac notice -ChanServ- Error: Value out of range.
  98.       unset %incdec.*
  99.       return
  100.     }
  101.  
  102.     .msg ChanServ access %incdec.chan $me
  103.     .msg ChanServ access %incdec.chan %incdec.nick
  104.   }
  105.  
  106.   else {
  107.     .timer 1 0 echo -tac -ChanServ- Currently processing command to inc/dec %incdec.nick $+ , please hold.
  108.   }
  109. }
  110.  
  111. alias incdec.timeout {
  112.   if ( %incdec.inuse ) {
  113.     echo -s incdec error: command timedout
  114.     unset %incdec.*
  115.   }
  116. }
  117.  
  118. on *:INPUT:#:{
  119.   if ( !$ctrlenter && ( $&
  120.     ( $1-2 == /msg ChanServ@Services.GameSurge.net && $left($3,1) == $chr(35) && $4 == inc ) || ( $1-2 == /msg ChanServ@Services.GameSurge.net && $left($3,1) == $chr(35) && $4 == dec ) || $&
  121.     ( $1-2 == /msg ChanServ && $left($3,1) == $chr(35) && $4 == inc ) || ( $1-2 == /msg ChanServ && $left($3,1) == $chr(35) && $4 == dec ) || $&
  122.     ( $1 == /cs && $left($2,1) == $chr(35) && $3 == inc ) || ( $1 == /cs && $left($2,1) == $chr(35) && $3 == dec ) || $&
  123.     ( $left($1,2) == !# && $2 == inc ) || ( $left($1,2) == !# && $2 == dec ) || $&
  124.     $1-3 == /msg ChanServ@Services.GameSurge.net inc || $1-3 == /msg ChanServ@Services.GameSurge.net dec || $&
  125.     $1-3 == /msg ChanServ inc || $1-3 == /msg ChanServ dec || $&
  126.     $1-2 == /cs inc || $1-2 == /cs dec || $&
  127.     $1 == !inc || $1 == !dec ) ) {
  128.  
  129.     if ( $1 == /msg ) {
  130.       echo -tac own -> * $+ $2 $+ * $3-
  131.     }
  132.     elseif ( $left($1,1) == ! ) {
  133.       .msg $chan $1-
  134.       echo -tac own < $+ $iif($me isop $chan,@,$iif($me isvoice $chan,+)) $+ $me $+ > $1-
  135.     }
  136.  
  137.     incdec.main $1-
  138.     haltdef
  139.   }
  140. }
  141.  
  142. ;Hide Helper/Oper title (if any)
  143. on ^*:NOTICE:$($+(%incdec.nick,$chr(32),is,*)):?:{
  144.   if ( %incdec.inuse ) {
  145.     haltdef
  146.   }
  147. }
  148.  
  149. ;catch $me access level
  150. on ^*:NOTICE:$($+(*,$me,$chr(32),$chr(40),*,$chr(41),$chr(32),has,$chr(32),access,*,in,$chr(32),%incdec.chan,$chr(46))):?:{
  151.   if ( %incdec.inuse ) {
  152.     set %incdec.level.me $strip($5)
  153.     haltdef
  154.   }  
  155. }
  156.  
  157. ;actual user level info
  158. on ^*:NOTICE:$($+(*,%incdec.nick,$chr(32),$chr(40),*,$chr(41),$chr(32),has,$chr(32),access,*,in,$chr(32),%incdec.chan,*)):?:{
  159.   if ( %incdec.inuse ) {
  160.     if ( !%incdec.level.me.no ) {
  161.       set %incdec.nick $1
  162.       set %incdec.handle $right($left($2,$calc($len($2)-1)),$calc($len($2)-2))
  163.       set %incdec.level.old $strip($5)
  164.       set %incdec.level.new %incdec.level.old
  165.  
  166.       if ( %incdec.inc ) {
  167.         if ( %incdec.value > $calc(%incdec.level.me - %incdec.level.old - 1 ) ) {
  168.           %incdec.value = $calc(%incdec.level.me - %incdec.level.old - 1 )
  169.           set %incdec.trim $chr(40) $+ Inc trimmed to %incdec.value $+ $chr(41)
  170.         }
  171.         %incdec.level.new = $calc(%incdec.level.new + %incdec.value)
  172.       }
  173.  
  174.       elseif ( %incdec.dec ) {
  175.         if ( $calc(%incdec.level.old - %incdec.value) < 1 ) {
  176.           %incdec.value = $calc(%incdec.level.old - 1 )
  177.           set %incdec.trim $chr(40) $+ Dec trimmed to %incdec.value $+ $chr(41)
  178.         }
  179.         %incdec.level.new = $calc(%incdec.level.new - %incdec.value)
  180.       }
  181.  
  182.       .msg ChanServ %incdec.chan clvl %incdec.nick %incdec.level.new
  183.       haltdef
  184.     }
  185.  
  186.     else {
  187.       echo -tac notice -ChanServ- You lack access to %incdec.chan $+ .
  188.       unset %incdec.*
  189.       haltdef
  190.     }
  191.   }
  192. }
  193.  
  194. ;hide any !setinfo (if any)
  195. on ^*:NOTICE:$($+($chr(91),%incdec.nick,$chr(93),*)):?:{
  196.   if ( %incdec.inuse ) {
  197.     haltdef
  198.   }
  199. }
  200.  
  201. ;hide !setinfo for $me
  202. on ^*:NOTICE:$($+($chr(91),$me,$chr(93),*)):?:{
  203.   if ( %incdec.inuse ) {
  204.     haltdef
  205.   }
  206. }
  207.  
  208. on *:NOTICE:$($+(User with nick,$chr(32),$chr(2),%incdec.nick,$chr(2),$chr(32),does not exist,$chr(46))):?:{
  209.   if ( %incdec.inuse ) {
  210.     unset %incdec.*
  211.   }
  212. }
  213.  
  214. on *:NOTICE:$($+($chr(2),%incdec.handle,$chr(2),$chr(32),outranks you,$chr(32),$chr(40),command has no effect,$chr(41),$chr(46))):?:{
  215.   if ( %incdec.inuse ) {
  216.     unset %incdec.*
  217.   }
  218. }
  219.  
  220. on *:NOTICE:$($+(*,$chr(32),is an invalid access level,$chr(46))):?:{
  221.   if ( %incdec.inuse ) {
  222.     unset %incdec.*
  223.   }
  224. }
  225.  
  226. ;add lacks access
  227. on ^*:NOTICE:$($+(*,lacks access to,*)):?:{
  228.   if ( %incdec.inuse ) {
  229.     if ( $1 == $me ) {
  230.       set %incdec.level.me.no 1
  231.       haltdef
  232.     }
  233.  
  234.     elseif ( $1 == %incdec.nick && $left($2,1) == $chr(40) && $right($2,1) == $chr(41) ) {
  235.       set %incdec.handle $right($left($2,$calc($len($2)-1)),$calc($len($2)-2))
  236.     }
  237.  
  238.     if ( $1 == %incdec.nick && !%incdec.level.me.no ) {
  239.       echo -tac notice -ChanServ- %incdec.handle lacks access to $chr(2) $+ %incdec.chan $+ $chr(2) $+ .
  240.       unset %incdec.*
  241.       haltdef
  242.     }
  243.  
  244.     elseif ( $1 == %incdec.nick && %incdec.level.me.no ) {
  245.       echo -tac notice -ChanServ- You lack access to %incdec.chan $+ .
  246.       unset %incdec.*
  247.       haltdef
  248.     }
  249.   }
  250. }
  251.  
  252. ;hide 'channel that exists'
  253. on ^*:NOTICE:$($+(You must provide the name of a channel that exists.)):?:{
  254.   if ( %incdec.inuse ) {
  255.     if ( !%incdec.exists ) {
  256.       set %incdec.exists 1
  257.       haltdef
  258.     }
  259.     else {
  260.       unset %incdec.*
  261.     }
  262.   }
  263. }
  264.  
  265. ;hide !clvl info
  266. on ^*:NOTICE:$($+(%incdec.handle,$chr(32),now has access,*,in,$chr(32),%incdec.chan,$chr(46))):?:{
  267.   if ( %incdec.inuse ) {
  268.     echo -tac notice -ChanServ- %incdec.nick $chr(40) $+ %incdec.handle $+ $chr(41) had access  $+ %incdec.level.old $+  $+ , but now has access  $+ %incdec.level.new $+  in %incdec.chan $+ . %incdec.trim
  269.     unset %incdec.*
  270.     haltdef
  271.   }
  272. }
  273.  
  274. on *:CONNECT:{
  275.   unset %incdec.*
  276. }
  277.  
  278. on *:START:{
  279.   unset %incdec.*
  280. }
  281.  
  282. on *:QUIT:{
  283.   if ( $nick == ChanServ ) {
  284.     unset %incdec.*
  285.   }
  286. }
  287.  
  288. on *:DISCONNECT:{
  289.   unset %incdec.*
  290. }
  291. on *:CONNECT:{
  292.   unset %incdec.*
  293. }
RAW Paste Data