コード例 #1
0
ファイル: MafiaValidate.php プロジェクト: numb95/pmg
 public function run()
 {
     $game = MafiaGame::getInstance();
     $server = Server::getInstance();
     $user = $this->parameters(1);
     /**
      if (self::$lastValidateTime == 0) {
      $user = $this->findUser($user);
      if (!$user)
      return;
      UserManager::remove($user);
      $server->whois($user);
      self::$lastValidateTime = time();
      self::$lastValidateUser = $user;
      }
     */
     //     if (time() - self::$lastValidateTime > 60) {
     $who = $this->findUser($user);
     //if (!$who) {
     //    $game->removeNick($who);
     // }
     $server->act($this->senderNick, "Validation of user {$user} done!");
     //    self::$lastValidateTime = 0;
     //     self::$lastValidateUser = '';
     //    }
     //    if (strtolower($user) == strtolower(self::$lastValidateUser) && self::$lastValidateUser != '') {
     //        $server->act($this->senderNick, "Another validate of user " . self::$lastValidateUser . " in progress! wait please.");
     //    }
 }
コード例 #2
0
 public function run()
 {
     $server = Server::getInstance();
     $server->notify($this->senderNick, "Disconnecting and reconnecting as according to config values...");
     $server->quit();
     sleep(3);
 }
コード例 #3
0
ファイル: MafiaOpt.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $opt = $this->parameters(1);
     if (!$opt) {
         $this->showStates();
         return;
     }
     $value = $this->parameters(2, true);
     switch (strtoupper($opt)) {
         case "SHOW-MAFIA":
             MafiaGame::$SHOW_MAFIA_COUNT = $value;
             break;
         case "MAFIA-STATE":
             MafiaGame::$WON_STATE_NORMAL = $value;
             break;
         case "DEAD-TALK":
             MafiaGame::$DEAD_IS_TALKING = $value;
             break;
         case "NIGHT-TIME":
             MafiaGame::$NIGHT_TIMEOUT = intval($value);
             if (MafiaGame::$NIGHT_TIMEOUT < 100) {
                 MafiaGame::$NIGHT_TIMEOUT = 100;
             }
             break;
         case "DAY-TIME":
             MafiaGame::$DAY_TIMEOUT = intval($value);
             if (MafiaGame::$DAY_TIMEOUT < 100) {
                 MafiaGame::$DAY_TIMEOUT = 100;
             }
             break;
     }
 }
コード例 #4
0
ファイル: MafiaVote.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     $I = $this->senderNick;
     $game->whosVote($I);
 }
コード例 #5
0
ファイル: WhoisResponseParser.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->eventType == ReceivedLineTypes::SERVERREPLYTHREEONEONE) {
         $workingLine = explode(" ", $this->runMessage, 8);
         $nick = $workingLine[3];
         $ident = $workingLine[4];
         $host = $workingLine[5];
         $realName = str_replace(":", "", $workingLine[7]);
         $realName = trim($realName);
         $user = new User();
         $user->nickname = $nick;
         $user->ident = $ident;
         $user->host = $host;
         $user->realName = $realName;
         UserManager::store($nick, $user);
     } else {
         if ($this->eventType == ReceivedLineTypes::SERVERREPLYTHREETHREEZERO || $this->eventType == ReceivedLineTypes::SERVERREPLYTHREEZEROSEVEN) {
             $workingLine = explode(" ", $this->runMessage);
             $nick = $workingLine[3];
             $user = UserManager::get($nick);
             $user->isIdentified = true;
             UserManager::store($nick, $user);
             if (Config::$users[$nick]) {
                 $permissionLevel = Config::$users[$nick];
             } else {
                 $permissionLevel = 0;
             }
             $server = Server::getInstance();
             $server->notify($nick, "You have been successfully authorized via NickServ with the permission level " . $permissionLevel);
         }
     }
 }
コード例 #6
0
 public function run()
 {
     Config::changeAllTimestampsToNow();
     DataManager::changeAllTimestampsToNow();
     $server = Server::getInstance();
     $server->notify($this->senderNick, "Database has reloaded all values from RAM");
 }
コード例 #7
0
ファイル: MafiaJoinChanel.php プロジェクト: numb95/pmg
 public function run()
 {
     $line = new ReceivedLine($this->runMessage);
     $line->parse();
     $user = UserManager::get($this->senderNick);
     $server = Server::getInstance();
     //$server->message($user->nickname, "Welcome to Persian Mafia game. This channel is logged, check this for more info : http://cyberrabbits.net/non/mafia/");
 }
コード例 #8
0
 public function run()
 {
     $server = Server::getInstance();
     $server->notify($this->senderNick, "Shutting down...");
     $server->quit();
     ErrorLog::log(ErrorCategories::NOTICE, "Killing script and all associated processes");
     die;
 }
コード例 #9
0
ファイル: MafiaTimeout.php プロジェクト: numb95/pmg
 public function run()
 {
     $game = MafiaGame::getInstance();
     $server = Server::getInstance();
     //if ($game->getState() != MAFIA_TURN) return;
     $server->act(MafiaGame::$LOBBY_ROOM, "Checking time out. please wait! request from : " . $this->senderNick);
     $game->checkNightTimeout();
 }
コード例 #10
0
ファイル: MafiaRaw.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->getLevel($this->senderNick) < 10) {
         return;
     }
     $server = Server::getInstance();
     $cmd = $this->parameters(1, true);
     $server->raw($cmd);
 }
コード例 #11
0
ファイル: MafiaReStartGame.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->getLevel($this->senderNick) < 10) {
         return;
     }
     $server = Server::getInstance();
     $game = MafiaGame::getInstance(true);
     $server->message(MafiaGame::$LOBBY_ROOM, "Game restarted!");
 }
コード例 #12
0
ファイル: UpdateTopic.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $channels = ChannelManager::getConnectedChannelArray();
     $server->notify($this->senderNick, "Flushed topic cache successfully");
     foreach ($channels as $channel) {
         $server->topic($channel);
     }
 }
コード例 #13
0
ファイル: Command.php プロジェクト: numb95/pmg
 /**
  * Execute the command through ModuleManager
  */
 public function execute()
 {
     $return = ModuleManager::runCommand($this->command, $this->fullMessage, $this->senderNick, $this->channel);
     if ($return !== true) {
         if ($return == 2) {
             $server = Server::getInstance();
             $server->notify($this->senderNick, "You do not have permission to use this command. Please identify via NickServ if you have privileges, then type " . Config::$commandCharacter . "identify");
         }
     }
 }
コード例 #14
0
ファイル: Join.php プロジェクト: JackHarley/AwesomeIRCBot
 public function run()
 {
     $channels = Config::getValue("channels");
     if (!in_array($this->parameters(1), $channels)) {
         $channels[] = $this->parameters(1);
     }
     Config::setValue("channels", $channels);
     $server = Server::getInstance();
     $server->join($this->parameters(1));
 }
コード例 #15
0
ファイル: Part.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->parameters(1)) {
         $channel = $this->parameters(1);
     } else {
         $channel = $this->channel;
     }
     $server = Server::getInstance();
     $server->part($channel);
 }
コード例 #16
0
ファイル: MafiaName.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->getLevel($this->senderNick) < 10) {
         return;
     }
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     $name = $this->parameters(1, true);
     MafiaGame::setGameName($name);
 }
コード例 #17
0
ファイル: MafiaKick.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->getLevel($this->senderNick) < 10) {
         return;
     }
     $server = Server::getInstance();
     $user = $this->parameters(1);
     $channel = $this->parameters(2);
     $message = $this->parameters(3);
     $server->kick($user, $channel, $message);
 }
コード例 #18
0
 public function run()
 {
     $server = Server::getInstance();
     $userPasswords = Config::getValue("userPasswords");
     if (!$userPasswords) {
         $userPasswords = array();
     }
     $userPasswords[$this->senderNick] = md5($this->parameters(1));
     Config::setValue("userPasswords", $userPasswords);
     $server->notify($this->senderNick, "Password for " . $this->senderNick . " set to " . $this->parameters(1));
 }
コード例 #19
0
ファイル: UserManager.php プロジェクト: numb95/pmg
 /**
  * Adds tracking for an online nick and stores
  * the given user object for them, if their nick is on the
  * privileged config list it also sends a WHOIS
  *
  * @param string online nickname
  * @param object User object
  */
 public static function store($nick, $userObject)
 {
     foreach (Config::$users as $privilegedUser => $level) {
         if ($nick == $privilegedUser) {
             if (!static::$trackedUsers[$nick]) {
                 $server = Server::getInstance();
                 $server->whois($nick);
             }
         }
     }
     static::$trackedUsers[$nick] = $userObject;
 }
コード例 #20
0
ファイル: MafiaStartGame.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->getLevel($this->senderNick) < 10) {
         return;
     }
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     $mafia = intval($this->parameters(1));
     $dr = intval($this->parameters(2));
     $det = intval($this->parameters(3));
     $no = intval($this->parameters(4));
     $game->start($mafia, $dr, $det, $no);
 }
コード例 #21
0
ファイル: Invite.php プロジェクト: numb95/pmg
 public function run()
 {
     if ($this->parameters(2)) {
         $channel = $this->parameters(2);
     } else {
         $channel = $this->channel;
     }
     $channelObject = ChannelManager::get($channel);
     if ($channelObject->hasPrivilegeOrHigher($this->senderNick, "@")) {
         $server = Server::getInstance();
         $server->channelInvite($this->parameters(1), $channel);
     }
 }
コード例 #22
0
ファイル: Monitor.php プロジェクト: JackHarley/AwesomeIRCBot
 public function run()
 {
     if (empty(static::$projects)) {
         $data = json_decode(file_get_contents(GITLAB_API_URL . "/v" . GITLAB_API_VERSION . "/groups/" . GITLAB_MONITOR_GROUP_ID . "?private_token=" . GITLAB_API_PRIVATE_TOKEN));
         foreach ($data->projects as $project) {
             static::$projects[$project->id] = $project;
         }
     }
     $latestAnnouncedEventDates = DataManager::retrieve("latestAnnouncedEvents");
     if (empty($latestAnnouncedEventDates)) {
         $firstRun = true;
     }
     $server = Server::getInstance();
     foreach (static::$projects as $project) {
         $events = json_decode(file_get_contents(GITLAB_API_URL . "/v" . GITLAB_API_VERSION . "/projects/" . $project->id . "/events?private_token=" . GITLAB_API_PRIVATE_TOKEN));
         $eventsToAnnounce = array();
         foreach ($events as $event) {
             if ($event->created_at == $latestAnnouncedEventDates[$project->id]) {
                 break;
             }
             $eventsToAnnounce[] = $event;
         }
         if ($events[0]->created_at) {
             if ($events[0]->created_at == $latestAnnouncedEventDates[$project->id]) {
                 continue;
             }
             $latestAnnouncedEventDates[$project->id] = $events[0]->created_at;
         }
         krsort($eventsToAnnounce);
         // events are given to us newest first by default, we want to
         // announce from oldest events to newest; hence reverse sorting
         if (!isset($firstRun)) {
             // don't announce anything on first run, or there will be spam
             foreach ($eventsToAnnounce as $event) {
                 switch ($event->target_type) {
                     case "Issue":
                         // TODO
                         break;
                     default:
                         if (isset($event->data->commits) && !empty($event->data->commits)) {
                             foreach ($event->data->commits as $commit) {
                                 $message = chr(2) . chr(3) . "9[COMMIT]" . chr(3) . " " . chr(3) . "13[" . $project->name . "]" . chr(3) . " " . chr(3) . "8[" . str_replace("refs/heads/", "", $event->data->ref) . "] " . chr(3) . chr(2) . $commit->author->name . " - " . $commit->message . " " . shortenURL($commit->url);
                                 $server->message(GITLAB_ANNOUNCE_CHANNEL, $message);
                             }
                         }
                 }
             }
         }
     }
     DataManager::store("latestAnnouncedEvents", $latestAnnouncedEventDates);
 }
コード例 #23
0
 public function run()
 {
     $action = $this->parameters(1);
     $server = Server::getInstance();
     switch ($action) {
         case "load":
             $moduleNamespace = "modules\\" . strtolower($this->parameters(2)) . "\\configs\\" . $this->parameters(2);
             ModuleManager::loadModuleConfig($moduleNamespace);
             $server->notify($this->senderNick, "Action completed");
             break;
         case "unload":
             $moduleNamespace = "modules\\" . strtolower($this->parameters(2)) . "\\configs\\" . $this->parameters(2);
             ModuleManager::unloadModuleConfig($moduleNamespace);
             $server->notify($this->senderNick, "Action completed");
             break;
         default:
             $folder = opendir(__DIR__ . "/..");
             $modulePacks = array();
             while (($file = readdir($folder)) !== false) {
                 if ($file != "." && $file != ".." && $file != "modules.inc.php" && $file != ".DS_Store") {
                     $folder2 = opendir(__DIR__ . "/../" . $file . "/configs");
                     while (($file2 = readdir($folder2)) !== false) {
                         if ($file2 != "." && $file2 != ".." && $file2 != ".DS_Store") {
                             $modulePacks[] = str_replace(".php", "", $file2);
                         }
                     }
                     closedir($folder2);
                 }
             }
             closedir($folder);
             $server->message($this->senderNick, "************************************");
             $server->message($this->senderNick, "Module Pack Listing");
             $server->message($this->senderNick, " ");
             foreach ($modulePacks as $modulePack) {
                 $modulePackLength = strlen($modulePack);
                 $spacesToAdd = 25 - $modulePackLength;
                 for ($i = 1; $i < $spacesToAdd; $i++) {
                     $spaces .= " ";
                 }
                 if (ModuleManager::isLoaded($modulePack)) {
                     $server->message($this->senderNick, $modulePack . $spaces . " - " . chr(2) . chr(3) . "3Loaded" . chr(3) . chr(2));
                 } else {
                     $server->message($this->senderNick, $modulePack . $spaces . " - " . chr(2) . chr(3) . "4Not Loaded" . chr(3) . chr(2));
                 }
                 unset($spaces);
             }
             $server->message($this->senderNick, "************************************");
             break;
     }
 }
コード例 #24
0
ファイル: MafiaWish.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     $I = $this->senderNick;
     if ($game->getState() == MAFIA_TURN) {
         $server->message($I, "A wish in night? you are crazy!");
         return;
     }
     if (!$game->isIn($I)) {
         $server->message($I, "You are not in game ;) may be next time");
         return;
     }
     $wish = $this->parameters(1, true);
     $game->thisIsMyLastWish($I, $wish);
 }
コード例 #25
0
ファイル: Part.php プロジェクト: JackHarley/AwesomeIRCBot
 public function run()
 {
     if ($this->parameters(1)) {
         $channel = $this->parameters(1);
     } else {
         $channel = $this->channel;
     }
     $channels = Config::getValue("channels");
     foreach ($channels as $offset => $value) {
         if ($value == $channel) {
             unset($channels[$offset]);
         }
     }
     Config::setValue("channels", $channels);
     $server = Server::getInstance();
     $server->part($channel);
 }
コード例 #26
0
 public function run()
 {
     $action = $this->parameters(1);
     $server = Server::getInstance();
     switch ($action) {
         case "set":
             Config::setValue($this->parameters(2), $this->parameters(3, true));
             $server->notify($this->senderNick, "Config key '" . $this->parameters(2) . "' set to '" . $this->parameters(3, true) . "'");
             break;
         case "get":
             $value = Config::getValue($this->parameters(2));
             if (!$value) {
                 $server->notify($this->senderNick, "Config key '" . $this->parameters(2) . "' is not set");
             }
             $server->notify($this->senderNick, $this->parameters(2) . " => " . $value);
             break;
     }
 }
コード例 #27
0
ファイル: PrivilegedUserControls.php プロジェクト: numb95/pmg
 public function run()
 {
     $action = $this->parameters(1);
     $user = $this->parameters(2);
     $level = $this->parameters(3);
     $server = Server::getInstance();
     switch ($action) {
         case "add":
             Config::$users[$user] = $level;
             $server->notify($this->senderNick, $user . " added to privileged users list at level " . $level);
             break;
         case "del":
             unset(Config::$users[$user]);
             $server->notify($this->senderNick, $user . " removed from privileged users list");
             break;
     }
     $server->whois($user);
 }
コード例 #28
0
ファイル: Help.php プロジェクト: numb95/pmg
 public function run()
 {
     $command = $this->parameters(1);
     if ($command) {
         $subcommand = $this->parameters(2);
         if ($subcommand != "") {
             $description = HelpManager::getDescription($command, $subcommand);
             $parameters = HelpManager::getParameters($command, $subcommand);
             $subcommandsString = false;
         } else {
             $description = HelpManager::getDescription($command);
             $parameters = HelpManager::getParameters($command);
             $subcommands = HelpManager::getSubcommands($command);
             foreach ($subcommands as $id => $subcommandOfCommand) {
                 if ($subcommandOfCommand != "BASE") {
                     $subcommandsString .= " " . $subcommandOfCommand;
                 }
             }
         }
         $server = Server::getInstance();
         $server->notify($this->senderNick, "************************************");
         $server->notify($this->senderNick, "Help for " . Config::$commandCharacter . $command . " " . $subcommand);
         $server->notify($this->senderNick, " ");
         $server->notify($this->senderNick, $description);
         $server->notify($this->senderNick, chr(2) . "Syntax: " . chr(2) . Config::$commandCharacter . $command . " " . $subcommand . " " . $parameters);
         if ($subcommandsString) {
             $server->notify($this->senderNick, chr(2) . "Subcommands:" . chr(2) . $subcommandsString);
         }
         $server->notify($this->senderNick, "************************************");
     } else {
         $commands = HelpManager::getCommandList();
         foreach ($commands as $id => $commandFromList) {
             $commandsString .= " " . $commandFromList;
         }
         $server = Server::getInstance();
         $server->notify($this->senderNick, "************************************");
         $server->notify($this->senderNick, "Welcome to AwesomeBot v2 Help");
         $server->notify($this->senderNick, "Follow @AwesomezGuy on Twitter http://twitter.com/AwesomezGuy");
         $server->notify($this->senderNick, "");
         $server->notify($this->senderNick, chr(2) . "Commands: " . chr(2) . $commandsString);
         $server->notify($this->senderNick, chr(2) . "Getting help with commands: " . chr(2) . Config::$commandCharacter . "help <command to get help for>");
         $server->notify($this->senderNick, "************************************");
     }
 }
コード例 #29
0
ファイル: MafiaHeal.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     $I = $this->senderNick;
     if ($game->getState() != MAFIA_TURN) {
         $server->message($I, "Not healing time!");
         return;
     }
     if (!$game->isIn($I)) {
         $server->message($I, "You are not in game ;) may be next time");
         return;
     }
     $you = $this->parameters(1);
     if (!$game->isIn($you) && $you != "*" && $you != "-") {
         $server->message($I, "{$you} is not in game ;) are you in love with him/her?");
         return;
     }
     $game->iSayHealYou($I, $you);
 }
コード例 #30
0
ファイル: MafiaPunish.php プロジェクト: numb95/pmg
 public function run()
 {
     $server = Server::getInstance();
     $game = MafiaGame::getInstance();
     if ($game->getState() != DAY_TURN) {
         $server->message($I, "Not punish time!");
         return;
     }
     $I = $this->senderNick;
     if (!$game->isIn($I)) {
         $server->message($I, "You are not in game ;) may be next time");
         return;
     }
     $you = $this->parameters(1);
     if (!$game->isIn($you) && $you != '-') {
         $server->message($I, "{$you} is not in game ;) so why hate him/her this much?");
         return;
     }
     $game->iSayPunishYou($I, $you);
 }