Advertisement
Guest User

Untitled

a guest
Feb 18th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.75 KB | None | 0 0
  1. <?php
  2. abstract class mod_operator {
  3.     static $level;
  4.     public static function errorNotOp($e){
  5.         irc::chanmsg($e->sid,$e->chan,"sorry, but i need operator status for that!");
  6.     }
  7.     public static function privmsg ($e){
  8.         $u=user::info($e);
  9.         if (isset($u['level'])) {
  10.             $list=array_slice(explode(" ",$e->text),1);                    
  11.             switch ($e->command){
  12.                 case '.greet':
  13.                     if ((int)$u['level']>=module::$list['privmsg']['.greet']['level']) {
  14.                         if (isset($list[0])){
  15.                             $o->id=$u['id'];
  16.                             if ($u['level']<=1) $o->level=2;
  17.                             $o->pass=$list[0];
  18.                             user::update($o);
  19.                         }
  20.                     }
  21.                 break;
  22.                 case '.info':
  23.                     if ((int)$u['level']>=module::$list['privmsg']['.info']['level']) {
  24.                         if (isset($list[0])){
  25.                             $o->id=$u['id'];
  26.                             $o->info=implode(" ",$list);
  27.                             user::update($o);
  28.                         }
  29.                     }
  30.                 break;         
  31.                 case '.update':
  32.                     if ((int)$u['level']>=module::$list['privmsg']['.update']['level']) {
  33.                         $o->nick=$list[0];
  34.                         $o->{$list[1]}=implode(" ",array_slice($list,2));
  35.                         user::update($o);
  36.                     }
  37.                 break;             
  38.             }
  39.         }      
  40.     }
  41.     public static function chanmsg ($e){
  42.         $u=user::info($e);
  43.         if (isset($u['level'])) {
  44.             $list=array_slice(explode(" ",str_replace("me",$e->nick,$e->text)),1);                     
  45.             $e->to=$list;
  46.             switch ($e->command){
  47.                 case '.o':
  48.                     if ((int)$u['level']>=module::$list['chanmsg']['.o']['level']) {
  49.                         if(count($list)>0) irc::op($e); else irc::op($e);
  50.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  51.                 break;
  52.                 case '.-o':
  53.                     if ((int)$u['level']>=module::$list['chanmsg']['.-o']['level']) {
  54.                         if(count($list)>0)irc::deop($e);else irc::deop($e);
  55.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  56.                 break;         
  57.                 case '.v':
  58.                     if ((int)$u['level']>=module::$list['chanmsg']['.v']['level']) {
  59.                         if(count($list)>0)irc::voice($e);else irc::voice($e);
  60.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  61.                 break; 
  62.                 case '.-v':
  63.                     if ((int)$u['level']>=module::$list['chanmsg']['.-v']['level']) {
  64.                         if(count($list)>0)irc::devoice($e);else irc::devoice($e);
  65.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  66.                 break;             
  67.                 case '.b':
  68.                     if ((int)$u['level']>=module::$list['chanmsg']['.b']['level']) {
  69.                         if(count($list)>0)irc::ban($list,$e->chan);else irc::chanmsg($e->chan,"empty list.");
  70.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  71.                 break; 
  72.                 case '.-b':
  73.                     if ((int)$u['level']>=module::$list['chanmsg']['.-b']['level']) {
  74.                         if(count($list)>0)irc::unban($list,$e->chan);else irc::chanmsg($e->chan,"empty list.");
  75.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  76.                 break;                 
  77.                 case '.q':
  78.                     if ((int)$u['level']>=module::$list['chanmsg']['.q']['level']) {
  79.                         if(count($list)>0)irc::mute($list,$e->chan);else irc::chanmsg($e->chan,"empty list.");
  80.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  81.                 break; 
  82.                 case '.-q':
  83.                     if ((int)$u['level']>=module::$list['chanmsg']['.-q']['level']) {
  84.                         if(count($list)>0)irc::unmute($list,$e->chan);else irc::chanmsg($e->chan,"empty list.");
  85.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  86.                 break;                 
  87.                 case '.t':
  88.                     if ((int)$u['level']>=module::$list['chanmsg']['.t']['level']) {
  89.                         $e->to=implode(" ",array_slice(explode(" ",$e->text),1));
  90.                         irc::topic($e);
  91.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  92.                 break;
  93.                 case '.off':
  94.                     if ((int)$u['level']>=module::$list['chanmsg']['.off']['level']) {
  95.                         $e->text=implode(" ",array_slice(explode(" ",$e->text),1));
  96.                         irc::quit($e);
  97.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  98.                 break;
  99.                 case '.r':
  100.                     if ((int)$u['level']>=module::$list['chanmsg']['.r']['level']) {
  101.                         $e->text=implode(" ",array_slice(explode(" ",$e->text),1));
  102.                         irc::restart($e);
  103.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  104.                 break;             
  105.                 case '.reload':
  106.                     if ((int)$u['level']>=module::$list['chanmsg']['.reload']['level']) {
  107.                         irc::reload();
  108.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  109.                 break;                             
  110.                 case '.k':
  111.                     if ((int)$u['level']>=module::$list['chanmsg']['.k']['level']) {
  112.                         $list=explode(" ",$e->text);
  113.                         $reason=implode(" ",array_slice(explode(" ",$e->text),2));
  114.                         $e->reason=$reason;
  115.                         $e->to=$list[1];
  116.                         irc::kick($e);
  117.                     }else irc::chanmsg($e->sid,$e->chan,"sorry, but you need more power to do that.");
  118.                 break;
  119.                 case '.ul':
  120.                     if ((int)$u['level']>=module::$list['chanmsg']['.ul']['level']) {
  121.                         $out="";
  122.                         foreach (irc::$channels as $chan=>$ul){
  123.                             $out.=sprintf("%s:[",$chan);
  124.                             foreach($ul as $nick){$out.=sprintf("%s,",$nick);}
  125.                             $out=substr($out,0,-1)."]";
  126.                         }
  127.                         irc::chanmsg($e->sid,$e->chan,$out);
  128.                     }
  129.                 break;
  130.                 case '.help':
  131.                     $out="";
  132.                     $exp=explode(" ",$e->text);
  133.                     if (!isset($exp[1])) {
  134.                         $el=module::eventList();
  135.                         $out.=sprintf("event[%s]:[",'global');
  136.                     } else {
  137.                         $el=module::eventList($exp[1]);
  138.                         $out.=sprintf("event[%s]:[",$exp[1]);
  139.                     }
  140.                     if (count($el)>0){
  141.                         foreach($el as $key=>$list){
  142.                             if (!isset($exp[1])){
  143.                                 $out.=sprintf("[%s]:[",$key);
  144.                                 foreach($list as $subkey=>$info) {
  145.                                     if ($u['level']>=$info['level'])$out.=sprintf("[%s]:level(%s),",$subkey,$info['level']);
  146.                                 }
  147.                                 $out=substr($out,0,-1);
  148.                                 $out.="],";
  149.                             } elseif (isset($exp[1])&&!isset($exp[2])&&isset(module::$list[$exp[1]])) {
  150.                                 $out.=sprintf("[%s]:level(%s),",$key,module::$list[$exp[1]][$key]['level']);
  151.                             } elseif (isset($exp[1])&&isset($exp[2])&&isset(module::$list[$exp[1]])&&isset(module::$list[$exp[1]][$exp[2]])) {
  152.                                 $out=sprintf("[%s]:[%s",$exp[2],module::$list[$exp[1]][$exp[2]]['info']);
  153.                             } else $out=sprintf("[%s]:[no such command.",$exp[2]);
  154.                         }
  155.                         $out=substr($out,0,-1);
  156.                         $out.="]";
  157.                         irc::chanmsg($e->sid,$e->chan,$out);
  158.                     }
  159.                 break;             
  160.             }
  161.         }
  162.     }
  163.     public static function init(){
  164.         $o->type="chanmsg";
  165.         $o->event->plugin="mod_operator";
  166.         $o->event->func="chanmsg";     
  167.         $o->event->commandlist=
  168.             array(
  169.                 array(".o",80,'gives op on channel.'),
  170.                 array(".-o",85,'takes user op on channel.'),
  171.                 array(".v",70,'gives user voice on channel.'),
  172.                 array(".-v",75,'takes user voice on channel'),
  173.                 array(".b",85,'bans user on channel'),
  174.                 array(".-b",70,'unbans user on channel'),
  175.                 array(".q",85,'mutes user on channel'),
  176.                 array(".-q",60,'unmutes user on channel'),
  177.                 array(".k",85,'kick user from channel'),
  178.                 array(".off",100,'halts the bot process'),
  179.                 array(".r",100,'restarts the bot.'),
  180.                 array(".reload",100,'reloads the system without killing the bot.'),
  181.                 array(".t",60,'changes channel topic'),
  182.                 array(".ul",95,'user list'),
  183.                 array(".help",1,'help!')
  184.             );
  185.         module::eventAdd($o);
  186.         unset($o);
  187.         $o->type="privmsg";
  188.         $o->event->plugin="mod_operator";
  189.         $o->event->func="privmsg";             
  190.         $o->event->commandlist=
  191.             array(
  192.                 array('.greet',1,'greet the bot with your pass to gain more level!'),
  193.                 array('.info',2,'set your personal info'),
  194.                 array('.update',100,"lets the owner update the bot user's")
  195.             );
  196.         module::eventAdd($o);
  197.         unset($o);
  198.         $o->type="errornotop";
  199.         $o->event->plugin="mod_operator";
  200.         $o->event->func="errorNotOp";  
  201.         $o->event->command="errornotop";
  202.         module::eventAdd($o);
  203.     }
  204. }
  205. mod_operator::init();
  206. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement