Пример #1
0
 public function pluginList($data)
 {
     //Computing server list for each plugin
     $servers = array();
     foreach (Leelabot::$instance->plugins->getInfoFromFiles() as $plugin) {
         $servers[$plugin['name']] = array();
     }
     foreach (ServerList::getList() as $servername) {
         $server = ServerList::getServer($servername);
         $list = $server->getPlugins();
         foreach ($list as $p) {
             if (!isset($servers[$p])) {
                 $servers[$p] = array();
             }
             $servers[$p][] = $servername;
         }
     }
     foreach ($servers as &$s) {
         if (empty($s)) {
             $s = 'Not used';
         } else {
             $s = join(', ', $s);
         }
     }
     $this->_dispatcher->parser->assign('plugins', Leelabot::$instance->plugins->getInfoFromFiles());
     $this->_dispatcher->parser->assign('loaded', Leelabot::$instance->plugins->getLoadedPlugins());
     $this->_dispatcher->parser->assign('servers', $servers);
     return $this->_dispatcher->parser->draw('plugins');
 }
Пример #2
0
 public function CommandBroadcast($id, $command)
 {
     $servers = ServerList::getList();
     $message = join(" ", $command);
     foreach ($servers as $server) {
         ServerList::getServerRCon($server)->say($message, array(), FALSE);
     }
 }
Пример #3
0
 public function RoutineMessages()
 {
     // We browse all servers
     $servers = ServerList::getList();
     foreach ($servers as $serv) {
         $server = ServerList::getServer($serv);
         $rcon = ServerList::getServerRCon($serv);
         $_messages = $server->get('msgs');
         $count = count($_messages);
         if ($this->config[$serv]['Active'] and $count) {
             $_lasttime = $server->get('lasttime');
             $_lastmsg = $server->get('lastmsg');
             $time = time();
             if ($time >= $_lasttime + $this->config[$serv]['EverySeconds']) {
                 $last = end($_messages);
                 $first = reset($_messages);
                 $msg = $first;
                 // If $_lastmsg is at the end of $_messages, we take the first value of $_messages
                 if ($last !== $_lastmsg) {
                     $while = TRUE;
                     while ($while) {
                         if ($msg == $_lastmsg) {
                             $while = FALSE;
                         }
                         $msg = next($_messages);
                     }
                 }
                 $rcon->say($msg, array(), FALSE);
                 $server->set('lastmsg', $msg);
                 $server->set('lasttime', $time);
             }
         }
     }
 }
Пример #4
0
 public function IrcPlayers($pseudo, $channel, $cmd, $message)
 {
     $serverlist = ServerList::getList();
     $actual = Server::getName();
     if (isset($cmd[1]) && in_array($cmd[1], $serverlist)) {
         Server::setServer($this->_main->servers[$cmd[1]]);
         $this->_printPlayers($cmd[1]);
     } else {
         foreach ($serverlist as $server) {
             Server::setServer($this->_main->servers[$server]);
             $this->_printPlayers();
         }
     }
     Server::setServer($this->_main->servers[$actual]);
 }
Пример #5
0
 public function IrcServerList($pseudo, $channel, $cmd, $message)
 {
     $serverlist = ServerList::getList();
     LeelaBotIrc::sendMessage("Servers : " . join(', ', $serverlist));
 }
Пример #6
0
 public function IrcNextMap($pseudo, $channel, $cmd, $message)
 {
     $serverlist = ServerList::getList();
     $server = LeelaBotIrc::nameOfServer($cmd[1]);
     if ($server !== false) {
         $rcon = ServerList::getServerRCon($server);
         $serverlist = ServerList::getList();
         if (in_array($cmd[1], $serverlist)) {
             $map = $cmd[2];
         } else {
             $map = $cmd[1];
         }
         if (isset($map)) {
             if (in_array($map, $this->_mapUt4List)) {
                 $rcon->set('g_nextmap "ut4_' . $map . '"');
             } else {
                 $rcon->set('g_nextmap "' . $map . '"');
             }
             LeelaBotIrc::sendMessage("Next map changed !");
         } else {
             LeelaBotIrc::sendMessage("What's name of the map ?");
         }
     }
 }
Пример #7
0
 public function RoutineWarns()
 {
     // We browse all servers
     $servers = ServerList::getList();
     foreach ($servers as $serv) {
         $server = ServerList::getServer($serv);
         $rcon = ServerList::getServerRCon($serv);
         $_warns = $server->get('warns');
         if (count($_warns)) {
             foreach ($_warns as $player => $warns) {
                 if ($warns['num'] >= $this->config['WarnsKick'] && time() >= $warns['last'] + $this->config['SecondsBeforeKick']) {
                     $rcon->tell($player, 'You have $warns warnings. You will be kicked', array('warns' => $warns['num']));
                     $this->_clearWarn($player, $server);
                     $rcon->kick($player);
                 }
             }
         }
     }
 }