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


PHP Services::getConnection方法代码示例

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


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

示例1: 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, $this->originalName)) {
         return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
     }
     if (count($messageEx) == 2) {
         // check target access
         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'));
         } else {
             Services::getConnection()->getProtocol()->sendKick($this->bot->getUuid(), $target, $messageEx[1], $user->getNick());
         }
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     } else {
         unset($messageEx[0]);
         $username = $messageEx[1];
         unset($messageEx[1]);
         // check target access
         // todo: abort when target has no account
         if ($access < $this->bot->getAccess($target, Services::getUserManager()->getUserByNick($username)->accountname)) {
             return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
         } else {
             Services::getConnection()->getProtocol()->sendKick($this->bot->getUuid(), $target, $username, $user->getNick() . ': ' . implode(' ', $messageEx));
         }
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:38,代码来源:CommandKick.class.php

示例2: 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

示例3: __construct

 /**
  * Creates a new instance of type Bot
  *
  * @param	UserType	$bot
  */
 public function __construct(UserType $bot, $trigger = '')
 {
     $this->bot = $bot;
     $this->trigger = $trigger;
     $this->registerEvents();
     // join channel
     $this->join(Services::getConnection()->getProtocol()->getServiceChannel());
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:13,代码来源:BotModule.class.php

示例4: setAccount

 /**
  * Sets the accountname for the given uuid
  *
  * @param	string	$uuid
  * @param	string	$accountname
  * @retuen	void
  */
 public function setAccount($uuid, $accountname)
 {
     Services::getUserManager()->getUser($uuid)->accountname = $accountname;
     if (isset($this->accountToUser[$accountname])) {
         $this->accountToUser[$accountname][] = $uuid;
     } else {
         $this->accountToUser[$accountname] = array($uuid);
     }
     // set umode +r
     Services::getConnection()->getProtocol()->sendMode($this->getUuid(), $uuid, '+r');
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:18,代码来源:AuthServ.class.php

示例5: 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

示例6: add

 /**
  * Add an item to the server
  * Note: Stores variable var with key only if such key doesn't exist at the server yet
  *
  * @param	string	$key
  * @param	mixed	$var
  * @param	integer	$expire
  * @return	void
  */
 public function add($key, $var, $expire = self::CACHE_TIMEOUT)
 {
     // add to log
     $this->cacheList[$key] = array('timestamp' => time(), 'value' => $var);
     // add to cache
     if (self::get($key) !== false) {
         parent::set($key, $var, MEMCACHE_COMPRESSED, $expire);
     } else {
         parent::add($key, $var, MEMCACHE_COMPRESSED, $expire);
     }
     // log
     if (defined('DEBUG')) {
         Services::getConnection()->getProtocol()->sendLogLine("Stored key '" . $key . "' with hash '" . sha1(is_array(self::get($key)) ? serialize(self::get($key)) : self::get($key)) . "'");
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:24,代码来源:CacheSource.class.php

示例7: 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]);
     }
     $access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
     if ($access < $this->bot->getNeededAccess($target, $this->originalName)) {
         return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
     }
     if (count($messageEx) == 1) {
         $this->bot->setStandardModes($target);
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     } else {
         unset($messageEx[0]);
         $modeString = implode(' ', $messageEx);
         Services::getConnection()->getProtocol()->sendMode($this->bot->getUuid(), $target, str_replace(array('q', 'r', 'a', 'v', 'o', 'b', 'h', 'A', 'O', 'e', 'P'), '', $modeString));
         $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
     }
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:25,代码来源:CommandMode.class.php

示例8: 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);
     }
     if ($this->bot->isRegistered($target)) {
         return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.alreadyRegistered'));
     }
     $users = Services::getChannelManager()->getChannel($target)->getUserList();
     foreach ($users as $channelUser) {
         if ($channelUser['user']->getUuid() == $user->getUuid()) {
             if (stripos($channelUser['mode'], 'o')) {
                 $this->bot->register($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
                 Services::getConnection()->getProtocol()->sendMode($this->bot->getUuid(), $target, '+q ' . $user->getNick());
                 return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success', $target));
             }
         }
     }
     return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.noOp'));
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:27,代码来源:CommandCregister.class.php

示例9: __set

 /**
  * @see lib/system/user/AbstractUserType::__set()
  */
 public function __set($variable, $value)
 {
     parent::__set($variable, $value);
     // send metadata
     Services::getConnection()->getProtocol()->sendMetadata($this->getUuid(), $variable, $value);
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:9,代码来源:User.class.php

示例10: SERVER

 /**
  * Handles the SERVER command
  *
  * @param	string		$input
  * @param	array<string>	$inputEx
  * @return	void
  */
 public static function SERVER($input, $inputEx)
 {
     Services::getEvent()->fire(Services::getConnection()->getProtocol(), 'serverCreated', array('name' => $inputEx[2]));
     Services::getConnection()->getProtocol()->serverList[] = $inputEx[2];
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:12,代码来源:ProtocolHandler.class.php

示例11: unregister

 /**
  * Unregisters the channel
  *
  * @param	string	$channel
  * @return	void
  */
 public function unregister($channel)
 {
     // remove +r
     Services::getConnection()->getProtocol()->sendMode($this->getUuid(), $channel, '-r');
     $sql = "DELETE FROM\r\n\t\t\t\tchanserv_channels\r\n\t\t\tWHERE\r\n\t\t\t\tchannel = '" . escapeString($channel) . "'";
     Services::getDB()->sendQuery($sql);
     $sql = "DELETE FROM\r\n\t\t\t\tchanserv_channels_to_users\r\n\t\t\tWHERE\r\n\t\t\t\tchannel = '" . escapeString($channel) . "'";
     Services::getDB()->sendQuery($sql);
     $sql = "DELETE FROM\r\n\t\t\t\tchanserv_channel_accessLevel\r\n\t\t\tWHERE\r\n\t\t\t\tchannel = '" . escapeString($channel) . "'";
     Services::getDB()->sendQuery($sql);
     // part the channel
     $this->part($channel, 'Unregistered');
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:19,代码来源:ChanServ.class.php

示例12: createBotInstance

 /**
  * Creates a new bot instance
  * @param	string	$moduleAddress
  * @param	string	$trigger
  * @param	string	$nick
  * @param	string	$hostname
  * @param	string	$ident
  * @param	string	$ip
  * @param	string	$modes
  * @param	string	$gecos
  */
 public function createBotInstance($moduleAddress, $trigger, $nick, $hostname, $ident, $ip, $modes, $gecos)
 {
     // validate
     if (!$this->moduleLoaded($moduleAddress)) {
         throw new ModuleException("No module found at address " . $moduleAddress . "!");
     }
     // validate module information
     if ($this->moduleInformation[$moduleAddress]['type'] != 'Bot') {
         throw new ModuleException("You can only create instances of bot modules!");
     }
     // create bot user
     $user = Services::getConnection()->getProtocol()->createBot($nick, $hostname, $ident, $ip, $modes, $gecos);
     // create instance of BotModule
     $this->runningBots[$moduleAddress] = new $moduleAddress($user, $trigger);
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:26,代码来源:ModuleManager.class.php

示例13: sendQuit

 /**
  * Sends a QUIT to server
  * @param	string	$uuid
  * @param	string	$message
  */
 public function sendQuit($uuid, $message)
 {
     Services::getConnection()->sendLine($this->formateUserLine($uuid, "QUIT :" . $message));
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:9,代码来源:Protocol.class.php

示例14: quit

 /**
  * Sends a QUIT to server
  * @param	string	$message
  */
 public function quit($message = "Shutting down ...")
 {
     Services::getConnection()->getProtocol()->sendQuit($this->getUuid(), $message);
 }
开发者ID:Evil-Co-Legacy,项目名称:Evil-Co.de-Services,代码行数:8,代码来源:Bot.class.php


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