コード例 #1
0
ファイル: Commands.php プロジェクト: WildPHP/module-auth
 public function amiauthorizedCommand($command, $params, IrcDataObject $object)
 {
     $user = !empty($params) ? trim($params) : $object->getMessage()['nick'];
     $channel = $object->getTargets()[0];
     $authorized = $this->parent->nicknameIsTrusted($user);
     $message = $authorized ? $user . ' is authorized.' : $user . ' is NOT authorized.';
     $connection = $this->parent->getModule('Connection');
     $connection->write($connection->getGenerator()->ircPrivmsg($channel, $message));
 }
コード例 #2
0
 public function partCommand($command, $params, IrcDataObject $data)
 {
     $auth = $this->parent->getModule('Auth');
     if (!$auth->nicknameIsTrusted($data->getMessage()['nick'])) {
         return;
     }
     $channel = !empty($params) ? $params : $data->getTargets()[0];
     if (!Validation::isChannelName($channel) || !$this->parent->isInChannel($channel)) {
         return;
     }
     $connection = $this->parent->getModule('Connection');
     $connection->write($connection->getGenerator()->ircPart($channel));
 }
コード例 #3
0
ファイル: Wiki.php プロジェクト: WildPHP/module-wiki
 /**
  * The wiki command itself.
  * @param IrcDataObject $data The data received.
  */
 public function wikiCommand($command, $params, IrcDataObject $data)
 {
     $params = trim($params);
     $user = $data->getMessage()['nick'];
     if (preg_match('/ @ ([\\S]+)$/', $params, $out) && !empty($out[1])) {
         $user = $out[1];
         $params = preg_replace('/ @ ([\\S]+)$/', '', $params);
     }
     // Merge multiple spaces into one, trim the result, urlencode it.
     $query = urlencode(trim(preg_replace('/\\s\\s+/', ' ', $params)));
     $url = $this->wikiURL . '/api.php?' . 'action=opensearch' . '&limit=1&namespace=0' . '&format=json&redirects=resolve&search=';
     $bodyResource = Remote::getUriBody($url . $query);
     $contents = $bodyResource->getContents();
     $result = json_decode($contents);
     $connection = $this->getModule('Connection');
     if ($result === false || empty($result[1])) {
         $connection->write($connection->getGenerator()->ircPrivmsg($data->getTargets()[0], $user . ': Sorry, I could not find a page matching your query. Please try again.'));
         return;
     }
     // OpenSearch API
     $title = $result[1][0];
     $link = $result[3][0];
     $connection->write($connection->getGenerator()->ircPrivmsg($data->getTargets()[0], $user . ': ' . $title . ' - ' . $link));
 }
コード例 #4
0
 public function updateChannelName(IrcDataObject $object)
 {
     if (!in_array($object->getCommand(), ['QUIT', 'JOIN', 'PART', 'KICK'])) {
         return;
     }
     $nick = $object->getMessage()['nick'];
     // kick command has the destination user set elsewhere; ['nick'] is the user executing the kick
     if ($object->getCommand() == 'KICK') {
         $nick = $object->getParams()['user'];
     }
     // true if user should be removed, false if he/she needs to be added
     $remove = $object->getCommand() != 'JOIN';
     foreach ($this->channelIndex as $channel) {
         if ($remove && $channel->userExists($nick)) {
             $channel->removeUser($nick);
         } elseif (!$channel->userExists($nick)) {
             $channel->addUser($nick);
         }
     }
 }
コード例 #5
0
ファイル: Auth.php プロジェクト: WildPHP/module-auth
 public function accountNotifyWatcher(IrcDataObject $object)
 {
     $nickname = $object->getMessage()['nick'];
     $accountname = trim($object->getParams());
     $this->accountMap[$nickname] = $accountname;
 }
コード例 #6
0
ファイル: Factoids.php プロジェクト: WildPHP/module-factoids
 public function removeGlobal($command, $params, IrcDataObject $object)
 {
     $nickname = $object->getMessage()['nick'];
     $channel = $object->getTargets()[0];
     $auth = $this->getModule('Auth');
     if (!$auth->nicknameIsTrusted($nickname)) {
         return;
     }
     $storage = $this->globalStorage;
     $key = trim($params);
     if (!$storage->exists($key)) {
         $connection = $this->getModule('Connection');
         $message = 'No such global factoid with key \'' . $key . '\'. ' . '(are you trying to remove a factoid for a specific channel?)';
         $connection->write($connection->getGenerator()->ircPrivmsg($channel, $message));
         return;
     }
     $storage->remove($key);
     $connection = $this->getModule('Connection');
     $message = 'Successfully removed global factoid with key \'' . $key . '\'.';
     $connection->write($connection->getGenerator()->ircPrivmsg($channel, $message));
 }