Example #1
0
 /**
  * @param $cmd
  * @param User $user
  * @param Channel $channel
  * @param $args
  * @return bool
  */
 public function handleCommand($cmd, User $user, Channel $channel, $args) : bool
 {
     $cmd = $this->connection->getCommandMap()->getCommand($cmd);
     if ($cmd instanceof CommandInterface) {
         if ($user->hasPermission($cmd->getMinimumPermission())) {
             if ($this->isBlocked($user) === false) {
                 $result = $this->connection->getPluginManager()->command($cmd, $args[1], $user, $channel);
                 if ($result === false and $cmd->getUsage() !== "") {
                     $ev = new CommandSendUsageTextEvent($cmd, $user, $channel, $args[1]);
                     if (!$ev->isCancelled()) {
                         $user->sendNotice("Usage: " . $cmd->getUsage());
                     }
                 }
             } else {
                 $user->sendNotice($this->config["message"]);
             }
         } else {
             $user->sendNotice($this->invalidPermissionsMsg);
         }
         return true;
     }
     return false;
 }