本文整理汇总了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'));
}
}
示例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());
}
}
}
}
}
}
示例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());
}
示例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');
}
示例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']);
}
}
}
示例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)) . "'");
}
}
示例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'));
}
}
示例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'));
}
示例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);
}
示例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];
}
示例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');
}
示例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);
}
示例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));
}
示例14: quit
/**
* Sends a QUIT to server
* @param string $message
*/
public function quit($message = "Shutting down ...")
{
Services::getConnection()->getProtocol()->sendQuit($this->getUuid(), $message);
}