当前位置: 首页>>代码示例>>PHP>>正文


PHP Services::getModuleManager方法代码示例

本文整理汇总了PHP中Services::getModuleManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Services::getModuleManager方法的具体用法?PHP Services::getModuleManager怎么用?PHP Services::getModuleManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Services的用法示例。


在下文中一共展示了Services::getModuleManager方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handleJoin

 /**
  * Handles joins on channels registered with chanserv
  * @param	string	$data
  */
 public function handleJoin($data)
 {
     // get chanserv address
     $chanserv = Services::getModuleManager()->lookupModule('ChanServ');
     // check for registered channel
     if (call_user_func(array($chanserv, 'isRegistered'), $data['channel'])) {
         foreach ($data['userList'] as $user) {
             // get user from array
             $user = $user['user'];
             // get channel access
             $access = Services::getModuleManager()->getBot($chanserv)->getAccess($data['channel'], $user->accountname);
             if ($access >= 500) {
                 Services::getConnection()->getProtocol()->sendMode(Services::getModuleManager()->getBot($chanserv)->getUuid(), $data['channel'], '+q ' . $user->getNick());
             } else {
                 if ($access >= Services::getModuleManager()->getBot($chanserv)->getNeededAccess($data['channel'], 'getOp')) {
                     Services::getConnection()->getProtocol()->sendMode(Services::getModuleManager()->getBot($chanserv)->getUuid(), $data['channel'], '+o ' . $user->getNick());
                 } else {
                     if ($access >= Services::getModuleManager()->getBot($chanserv)->getNeededAccess($data['channel'], 'getVoice')) {
                         Services::getConnection()->getProtocol()->sendMode(Services::getModuleManager()->getBot($chanserv)->getUuid(), $data['channel'], '+v ' . $user->getNick());
                     }
                 }
             }
         }
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:29,代码来源:JoinModeExtension.class.php

示例2: execute

 /**
  * @see lib/modules/CommandModule::execute()
  */
 public function execute($user, $target, $message)
 {
     $messageEx = explode(' ', $message);
     unset($messageEx[0]);
     // quit with a nice message
     if (count($messageEx)) {
         Services::getModuleManager()->shutdown(implode(' ', $messageEx));
     } else {
         Services::getModuleManager()->shutdown();
     }
     exit;
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:15,代码来源:CommandShutdown.class.php

示例3: handleKick

 /**
  * Handles an incoming KICK event
  * @param	array	$data
  */
 public function handleKick($data)
 {
     // get chanserv
     $chanserv = Services::getModuleManager()->lookupModule('ChanServ');
     // ignore unregistered channels
     if (call_user_func(array($chanserv, 'isRegistered'), $data['target'])) {
         // check permissions
         if (call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['issuer'])->accountname) < call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['victim'])->accountname) || call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['issuer'])->accountname) < call_user_func(array($chanserv, 'kick'), $data['target'])) {
             // rejoin victim if needed
             Services::getConnection()->getProtocol()->sendSvsjoin($data['victim'], $data['target']);
         }
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:17,代码来源:KickRevengeExtension.class.php

示例4: execute

 /**
  * @see lib/modules/CommandModule::execute()
  */
 public function execute($user, $target, $message)
 {
     // split message
     $messageEx = explode(' ', $message);
     // BIND <bot> <module> <command> <appearInHelp>
     if (count($messageEx) >= 3) {
         $botAddress = Services::getModuleManager()->lookupModule($messageEx[1]);
         $moduleAddress = Services::getModuleManager()->lookupModule($messageEx[2]);
         $commandName = $messageEx[3];
         $appearInHelp = (bool) (isset($messageEx[4]) ? $messageEx[4] : true);
         Services::getModuleManager()->bindCommand($botAddress, $moduleAddress, $commandName, $appearInHelp);
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     } else {
         // send syntax hint
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:20,代码来源:CommandBind.class.php

示例5: execute

 /**
  * @see lib/modules/CommandModule::execute()
  */
 public function execute($user, $target, $message)
 {
     // split message
     $messageEx = explode(' ', $message);
     if (count($messageEx) == 2 and !empty($messageEx[1])) {
         // get module name
         $moduleName = $messageEx[1];
         try {
             // try to load module
             Services::getModuleManager()->loadModule(SDIR . 'lib/modules/' . ucfirst($moduleName) . '.class.php');
         } catch (Exception $ex) {
             $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.cannotLoad', $ex->getMessage()));
         }
     } else {
         // send syntax hint
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:21,代码来源:CommandLoadModule.class.php

示例6: execute

 /**
  * @see lib/modules/CommandModule::execute()
  */
 public function execute($user, $target, $message)
 {
     // split message
     $messageEx = explode(' ', $message);
     if ($target[0] != '#') {
         $target = $messageEx[1];
         unset($messageEx[1]);
         $messageEx = array_values($messageEx);
     }
     $access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
     if ($access < $this->bot->getNeededAccess($target, 'access')) {
         return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
     }
     if (count($messageEx) == 3) {
         if ($messageEx[2] >= $access) {
             return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.tooHigh'));
         } else {
             if ($messageEx[2] > 500) {
                 return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.tooHigh'));
             }
         }
         if ($access <= $this->bot->getAccess($target, Services::getUserManager()->getUserByNick($messageEx[1])->accountname)) {
             return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
         }
         $authServ = Services::getModuleManager()->lookupModule('AuthServ');
         $userID = call_user_func(array($authServ, 'getUserID'), $messageEx[1]);
         if (!$userID) {
             return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.invalidUser'));
         }
         if ($messageEx[0] < 1) {
             $sql = "DELETE FROM chanserv_channels_to_users WHERE channel = '" . escapeString($target) . "' AND userID = " . $userID;
         } else {
             $sql = "INSERT INTO chanserv_channels_to_users (channel, userID, accessLevel)\n\t\t\t\t\tVALUES ('" . escapeString($target) . "', " . $userID . ", " . intval($messageEx[2]) . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE accessLevel = VALUES(accessLevel)";
         }
         Services::getDB()->sendQuery($sql);
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     } else {
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:43,代码来源:CommandChangeuser.class.php

示例7: PRIVMSG

 /**
  * Handles the PRIVMSG command
  *
  * @param	string		$input
  * @param	array<string>	$inputEx
  * @return	void
  */
 public static function PRIVMSG($input, $inputEx)
 {
     if ($inputEx[2][0] != '$') {
         // get source
         $source = Services::getUserManager()->getUser($inputEx[0]);
         if ($inputEx[2][0] == '#' and $source !== null) {
             // send debug message
             if (defined('DEBUG')) {
                 Services::getConnection()->getProtocol()->sendLogLine($source->getUuid() . " (" . $source->getNick() . ") sent a message to " . $inputEx[2]);
             }
             // notify module manager
             Services::getModuleManager()->handleLine($source, $inputEx[2], substr($input, stripos($input, ':') + 1));
         } elseif ($source) {
             // kick numeric
             $inputEx[2] = substr($inputEx[2], strlen(Services::getConnection()->getProtocol()->numeric));
             // send debug message
             if (defined('DEBUG')) {
                 Services::getConnection()->getProtocol()->sendLogLine($source->getUuid() . " (" . $source->getNick() . ") sent a message to " . $inputEx[2]);
             }
             // try to find bot
             if (($bot = Services::getBotManager()->getUser($inputEx[2])) !== null) {
                 // resolved uuid ... send debug message
                 if (defined('DEBUG')) {
                     Services::getConnection()->getProtocol()->sendLogLine("Resolved " . $inputEx[2] . " to " . $bot->getNick());
                 }
                 // notify module manager
                 Services::getModuleManager()->handleLine($source, $inputEx[2], substr($input, stripos($input, ':') + 1));
             } else {
                 // cannot find user ... send debug message
                 if (defined('DEBUG')) {
                     Services::getConnection()->getProtocol()->sendLogLine("Cannot resolve '" . $inputEx[2] . "'! Type of return value: " . gettype($bot));
                 }
             }
         } else {
             Services::getConnection()->getProtocol()->sendLogLine("Received invalid UUID '" . $inputEx[0] . "'! Maybe choosen wrong IRCd?");
         }
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:45,代码来源:ProtocolHandler.class.php

示例8: register

 /**
  * Registers the channel with chanserv
  *
  * @param	string	$channel
  * @param	string	$accountname
  * @return	void
  */
 public function register($channel, $accountname)
 {
     $authServ = Services::getModuleManager()->lookupModule('AuthServ');
     $userID = call_user_func(array($authServ, 'getUserID'), $accountname);
     $sql = "INSERT INTO chanserv_channels (channel, modes, time, registrar, unregistercode) VALUES ('" . escapeString($channel) . "', '+tnr', " . time() . ", " . $userID . ", '" . StringUtil::getRandomID() . "')";
     Services::getDB()->sendQuery($sql);
     $sql = "INSERT INTO chanserv_channels_to_users (channel, userID, accessLevel) VALUES ('" . escapeString($channel) . "', " . $userID . ", 500)";
     Services::getDB()->sendQuery($sql);
     $values = '';
     $sql = "SELECT\r\n\t\t\t\t*\r\n\t\t\tFROM\r\n\t\t\t\tchanserv_default_accessLevel";
     $result = Services::getDB()->sendQuery($sql);
     while ($row = Services::getDB()->fetchArray($result)) {
         if ($values != '') {
             $values .= ',';
         }
         $values .= "('" . escapeString($channel) . "', '" . $row['function'] . "', " . $row['accessLevel'] . ")";
     }
     $sql = "INSERT INTO chanserv_channel_accessLevel (channel, function, accessLevel) VALUES " . $values;
     Services::getDB()->sendQuery($sql);
     // join the channel
     $this->join($channel);
     // set modes
     $this->setStandardModes($channel, '+tnr');
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:31,代码来源:ChanServ.class.php

示例9: getPermissions

 /**
  * Checks for needed permissions and returns true if correct permissions are set
  *
  * @param 	UserType	$user
  * @param	integer		$neededPermissions
  * @return	boolean
  */
 public function getPermissions(UserType $user, $neededPermissions)
 {
     // when 0 always is okay
     if ($neededPermissions == 0) {
         return true;
     }
     // handle empty account names
     //if ($user->accountname === null or $user->accountname != '') return false;
     // check for correct level
     if (call_user_func(array(Services::getModuleManager()->lookupModule('AuthServ'), 'getAccessLevel'), $user->accountname) >= $neededPermissions) {
         return true;
     }
     return false;
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:21,代码来源:BotModule.class.php


注:本文中的Services::getModuleManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。