コード例 #1
0
 /**
  * Spits out the help
  *
  * @param	UserType	$user
  * @param	string		$target
  * @param	string		$message
  * @return	void
  */
 public function generateHelp(UserType $user, $target, $message)
 {
     $inputEx = explode(' ', $message);
     if (!isset($inputEx[1])) {
         $this->sendMessage($user->getUuid(), COLOR_BOLD . COLOR_UNDERLINE . Services::getLanguage()->get($user->languageID, 'bot.global.help', $this->getNick()) . COLOR_UNDERLINE . COLOR_BOLD);
         $longestCommandName = 0;
         foreach ($this->commands as $key => $command) {
             if ($command->appearInHelp and strlen($command->commandName) > $longestCommandName) {
                 $longestCommandName = strlen($command->commandName);
             }
         }
         foreach ($this->commands as $key => $command) {
             if ($command->appearInHelp and $this->getPermissions($user, $command->neededPermissions)) {
                 $this->sendMessage($user->getUuid(), str_pad($command->commandName, $longestCommandName + 3) . Services::getLanguage()->get($user->languageID, 'command.' . $command->originalName));
             }
         }
     } else {
         foreach ($this->commands as $key => $command) {
             if ($command->commandName == strtoupper($inputEx[1])) {
                 $this->sendMessage($user->getUuid(), $command->commandName);
                 $this->sendMessage($user->getUuid(), COLOR_BOLD . COLOR_UNDERLINE . "Syntax:" . COLOR_UNDERLINE . COLOR_BOLD . " " . Services::getLanguage()->get($user->languageID, 'command.' . $command->originalName . '.syntaxHint'));
                 if ($command->neededPermissions > 0) {
                     $this->sendMessage($user->getUuid(), COLOR_BOLD . Services::getLanguage()->get($user->languageID, 'bot.global.neededPermissions') . COLOR_BOLD . " " . $command->neededPermissions);
                 }
                 if (Services::getLanguage()->get($user->languageID, 'command.' . $command->originalName . '.description') != 'command.' . $command->originalName . '.description') {
                     $this->sendMessage($user->getUuid(), 'command.' . $command->originalName . '.description');
                 }
                 return;
             }
         }
         $this->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'bot.global.noSuchCommand'));
     }
 }