Example #1
0
File: QUIT.php Project: nkreer/Fish
 public static function run(Command $command, Connection $connection, JsonConfig $config)
 {
     //Tell the plugins that a user has quit
     $user = User::getUser($connection, $command->getPrefix());
     $ev = new UserQuitEvent($user);
     $connection->getEventHandler()->callEvent($ev);
     if (!$ev->isCancelled()) {
         Logger::info($user->getNick() . " quit");
         User::removeUser($connection, $user->getHostmask());
         // Remove user
     }
 }
Example #2
0
File: PART.php Project: nkreer/Fish
 public static function run(Command $command, Connection $connection, JsonConfig $config)
 {
     //Tell the plugins that a user has parted
     $channel = Channel::getChannel($connection, str_replace(":", "", $command->getArg(0)));
     $user = User::getUser($connection, $command->getPrefix());
     if ($user instanceof User) {
         $ev = new ChannelLeaveEvent($channel, $user);
         $connection->getEventHandler()->callEvent($ev);
         if (!$ev->isCancelled()) {
             Logger::info($user->getNick() . " left " . $channel->getName());
             User::removeUser($connection, $user->getHostmask());
             //Remove the user, don't care if they are in other channels the bot is in
         }
     }
 }
Example #3
0
File: NICK.php Project: nkreer/Fish
 public static function run(Command $command, Connection $connection, JsonConfig $config)
 {
     $user = User::getUser($connection, $command->getPrefix());
     $new = str_replace(":", "", $command->getArg(0));
     $ev = new UserChangeNickEvent($user->getNick(), $new);
     $connection->getEventHandler()->callEvent($ev);
     if (!$ev->isCancelled()) {
         Logger::info($user->getNick() . " is now known as " . $new);
         if ($user->getNick() === $connection->getNick()) {
             // Bot changed name
             $connection->nickname = $new;
         }
         User::removeUser($connection, $user->getHostmask());
         //Remove old authentication status, mainly
     }
 }
Example #4
0
 /**
  * @param User $user
  * @param String $reason
  */
 public function kick(User $user, string $reason = "Kicked.")
 {
     $this->connection->sendData("KICK " . $this->getName() . " " . $user->getNick() . " :" . $reason);
     User::removeUser($this->connection, $user->getHostmask());
     //Remove from connection
     $this->removeUser($user->getNick());
     // Remove from channel
 }