Added full source code

This commit is contained in:
Emmanuel BENOîT 2016-01-10 11:01:49 +01:00
commit 33f8586698
1377 changed files with 123808 additions and 0 deletions

View file

View file

@ -0,0 +1,81 @@
;+---------------------------------------------------------------------------
;| PHP-IRC Internal DCC Function Configuration File
;| ========================================================
;| by Manick
;| (c) 2001-2004 by http://phpbots.sf.net
;| Contact: manick@manekian.com
;| irc: #manekian@irc.rizon.net
;| ========================================
;+---------------------------------------------------------------------------
;| > This program is free software; you can redistribute it and/or
;| > modify it under the terms of the GNU General Public License
;| > as published by the Free Software Foundation; either version 2
;| > of the License, or (at your option) any later version.
;| >
;| > This program is distributed in the hope that it will be useful,
;| > but WITHOUT ANY WARRANTY; without even the implied warranty of
;| > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;| > GNU General Public License for more details.
;| >
;| > You should have received a copy of the GNU General Public License
;| > along with this program; if not, write to the Free Software
;| > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;+---------------------------------------------------------------------------
file dcc_mod modules/default/dcc_mod.php
privmsg dcc_mod monitor_check
mode dcc_mod monitor_check
join dcc_mod monitor_check
kick dcc_mod monitor_check
part dcc_mod monitor_check
;new feature in 2.2.0, section definitions
section standard "Standard Functions"
section channel "Channel Functions"
section dcc "DCC Functions"
section info "Information Functions"
section admin "Administrative Functions"
section comm "IRC/Communication Functions"
dcc monitor ~; command text (typed in dcc iface)
0 ~; number of required arguments
"<channel>" ~; argument descriptions <arg1> <arg2> (or however you damn well please to do it hehe ;)
"Show messages from channel in dcc chat interface" ~; description of command
true ~; must be admin to use this command?
dcc_mod ~; class name (see file import section above)
dcc_monitor ~; function name
channel ; section name
dcc exit 0 "" "Exits the DCC interface" false dcc_mod dcc_exit standard
dcc raw 1 "<raw query>" "Sends raw query to server" true dcc_mod dcc_raw comm
dcc who 0 "" "See who\'s online" false dcc_mod dcc_who standard
dcc ignore 0 "" "View ignore list" true dcc_mod dcc_ignore admin
dcc rignore 1 "<host>" "Remove ignore for a specified host" true dcc_mod dcc_rignore admin
dcc clearqueue 0 "<user>" "Removes all text queues, or queues for a specified user." true dcc_mod dcc_clearqueue admin
dcc server 1 "<server> <port>" "Change server to specified server" true dcc_mod dcc_server admin
dcc chat 1 "<text>" "Sends message to all admin users using the DCC interface" true dcc_mod dcc_chat comm
dcc restart 0 "" "Reconnect to the current server" true dcc_mod dcc_restart admin
dcc say 2 "<channel> <text>" "Sends text to some channel" true dcc_mod dcc_say comm
dcc action 2 "<channel> <text>" "Sends text to some channel in /me format" true dcc_mod dcc_action comm
dcc users 0 "" "Shows users in all channels" true dcc_mod dcc_users info
dcc maintain 0 "<channel> <key>" "Shows maintained channels, and adds or removes one" true dcc_mod dcc_maintain channel
dcc help 0 "" "Get information about command(s)" false dcc_mod dcc_help standard
dcc join 1 "<channel>" "Join a channel" true dcc_mod dcc_join channel
dcc part 1 "<channel>" "Part a channel" true dcc_mod dcc_part channel
dcc rejoin 1 "<channel>" "Rejoin a channel" true dcc_mod dcc_rejoin channel
dcc status 0 "" "Get status of bot, same as 5 minute status update" true dcc_mod dcc_status info
dcc function 0 "<activate/deactivate> <function>" "See which functions are activated, or activate/deactivate a function" true dcc_mod dcc_function admin
dcc reloadfunc 0 "" "Reloads function definition file" true dcc_mod dcc_reloadfunc admin
dcc shutdown 0 "" "Shuts the bot down" true dcc_mod dcc_shutdown admin
dcc connect 0 "" "Force connection to server when disconnected" true dcc_mod dcc_connect admin
dcc rehash 0 "" "Reload the configuration file" true dcc_mod dcc_rehash admin
dcc send 2 "<nick> <file>" "Send a user a file" true dcc_mod dcc_send dcc
dcc dcc 0 "" "Check current dcc status" true dcc_mod dcc_dccs dcc
dcc close 1 "<id>" "Close a download, upload, or chat window" true dcc_mod dcc_close dcc
dcc upload 1 "<yes/no>" "Allow files to be sent to this bot" true dcc_mod dcc_upload dcc
dcc botinfo 0 "" "View information about the bot" true dcc_mod dcc_botinfo info
dcc timers 0 "" "View active timer information" true dcc_mod dcc_timers info
dcc listul 0 "" "List upload directory contents" true dcc_mod dcc_listul dcc
dcc modules 0 "" "List installed modules" true dcc_mod dcc_modules info
dcc spawn 1 "<config file>" "Spawn a new bot in this process" true dcc_mod dcc_spawn admin

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
;+---------------------------------------------------------------------------
;| PHP-IRC Internal PRIVMSG Function Configuration File
;| ========================================================
;| by Manick
;| (c) 2001-2004 by http://phpbots.sf.net
;| Contact: manick@manekian.com
;| irc: #manekian@irc.rizon.net
;| ========================================
;+---------------------------------------------------------------------------
;| > This program is free software; you can redistribute it and/or
;| > modify it under the terms of the GNU General Public License
;| > as published by the Free Software Foundation; either version 2
;| > of the License, or (at your option) any later version.
;| >
;| > This program is distributed in the hope that it will be useful,
;| > but WITHOUT ANY WARRANTY; without even the implied warranty of
;| > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;| > GNU General Public License for more details.
;| >
;| > You should have received a copy of the GNU General Public License
;| > along with this program; if not, write to the Free Software
;| > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
;+---------------------------------------------------------------------------
file priv_mod modules/default/priv_mod.php
priv admin ~; text typed in the channel/pm (admin)
true ~; active command on statup?
false ~; inform admins in dcc chat iface if this command is used
false ~; can be deactivated with 'function' dcc command
0 ~; times used.. just leave this 0 (its for stats).
priv_mod ~; class name (see file import section above)
priv_admin ; function name
priv !ad true true true 0 priv_mod priv_ad

View file

@ -0,0 +1,315 @@
<?php
/*
+---------------------------------------------------------------------------
| PHP-IRC v2.2.0
| ========================================================
| by Manick
| (c) 2001-2005 by http://phpbots.sf.net/
| Contact: manick@manekian.com
| irc: #manekian@irc.rizon.net
| ========================================
+---------------------------------------------------------------------------
| > priv_mod module
| > Module written by Manick
| > Module Version Number: 2.2.0
+---------------------------------------------------------------------------
| > This program is free software; you can redistribute it and/or
| > modify it under the terms of the GNU General Public License
| > as published by the Free Software Foundation; either version 2
| > of the License, or (at your option) any later version.
| >
| > This program is distributed in the hope that it will be useful,
| > but WITHOUT ANY WARRANTY; without even the implied warranty of
| > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| > GNU General Public License for more details.
| >
| > You should have received a copy of the GNU General Public License
| > along with this program; if not, write to the Free Software
| > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+---------------------------------------------------------------------------
| Changes
| =======-------
| > If you wish to suggest or submit an update/change to the source
| > code, email me at manick@manekian.com with the change, and I
| > will look to adding it in as soon as I can.
+---------------------------------------------------------------------------
*/
class priv_mod extends module {
public $title = "Privmsg Utils";
public $author = "Manick";
public $version = "2.1.1";
public $dontShow = true;
private $ads;
public function init()
{
$this->loadAds();
}
public function destroy()
{
$this->destroyAds();
}
private function loadAds()
{
$ads = new ini("./modules/default/ads.ini");
if ($ads->getError())
{
return;
}
$sections = $ads->getSections();
foreach ($sections AS $ad)
{
$int = $ads->getIniVal($ad, "int");
$channel = $ads->getIniVal($ad, "chan");
$msg = $ads->getIniVal($ad, "msg");
$argArray = array('msg' => $msg, 'channel' => $channel);
$this->timerClass->addTimer($ad, $this, "misc_adTimer", $argArray, $int);
}
$this->ads = $ads;
}
private function destroyAds()
{
$sections = $this->ads->getSections();
foreach ($sections AS $ad)
{
$this->timerClass->removeTimer($ad);
}
}
// Misc Timer
public function misc_adTimer($msg)
{
$ad = DARK . "[" . BRIGHT . "Request" . DARK . "] - [" . BRIGHT .
$msg['msg'] . DARK .
"] - PHP-IRC v" . VERSION;
$raw = "PRIVMSG " . $msg['channel'] . " :" . $ad;
$this->ircClass->sendRaw($raw);
return true;
}
/* public Message/Channel Functions */
// This function is an example, it will display an add with timer
public function priv_ad($line, $args)
{
$channel = irc::myStrToLower($line['to']);
if ($channel == $this->ircClass->getNick())
{
return;
}
if (!$this->ircClass->isMode($line['fromNick'], $channel, "o"))
{
return;
}
if ($args['nargs'] == 0)
{
$timerString = "";
$timers = $this->timerClass->getTimers();
foreach ($timers AS $timer)
{
if (substr($timer->name, 0, 2) == "ad")
{
if ($timer->args['channel'] == $channel)
{
$timerString .= $timer->name . " ";
}
}
}
if ($timerString == "")
{
$this->ircClass->notice($line['fromNick'], "No ads currently for " . $channel . ".");
}
else
{
$this->ircClass->notice($line['fromNick'], "Current ads for " . $channel .":");
$this->ircClass->notice($line['fromNick'], $timerString);
}
$this->ircClass->notice($line['fromNick'], "Type !ad <interval(seconds)> <msg> to add an ad, or !ad <ad[id]> to view an ad.");
}
else if ($args['nargs'] >= 1)
{
if (substr($args['arg1'], 0, 2) == "ad" && strlen($args['arg1']) > 2)
{
$id = $args['arg1'];
$timers = $this->timerClass->getTimers();
foreach ($timers AS $timer)
{
if ($timer->name == $id)
{
break;
}
}
if ($timer == null || $channel != $timer->args['channel'])
{
$this->ircClass->notice($line['fromNick'], "There is no ad by that id.");
}
else
{
if ($args['nargs'] >= 2)
{
if (irc::myStrToLower($args['arg2']) == "delete")
{
$this->ads->deleteSection($timer->name);
$this->ads->writeIni();
$this->timerClass->removeTimer($timer->name);
$this->ircClass->notice($line['fromNick'], "Ad successfully deleted.");
}
else
{
$this->ircClass->notice($line['fromNick'], "Invalid option. Valid options: delete");
}
}
else
{
$this->ircClass->notice($line['fromNick'], "Ad: " . $timer->name);
$this->ircClass->notice($line['fromNick'], $timer->args['msg']);
$this->ircClass->notice($line['fromNick'], "Use '!ad " . $timer->name . " delete' to delete this ad.");
}
}
}
else
{
if ($args['nargs'] == 1)
{
$this->ircClass->notice($line['fromNick'], "You must specify a message!");
}
else
{
$int = intval($args['arg1']);
if ($int <= 5)
{
$this->ircClass->notice($line['fromNick'], "Invalid Interval. Interval must be greater than 5 seconds.");
}
else
{
$ad = substr($args['query'], strlen($args['arg1']) + 1);
$argArray = array('msg' => $ad, 'channel' => $channel);
//Find next id
$highest = 0;
$timers = $this->timerClass->getTimers();
foreach ($timers AS $timer)
{
if (substr($timer->name, 0, 2) == "ad")
{
$id = intval(substr($timer->name, 2));
if ($id > $highest)
{
$highest = $id;
}
}
}
$highest++;
$this->timerClass->addTimer('ad' . $highest, $this, "misc_adTimer", $argArray, $int, true);
$this->ircClass->notice($line['fromNick'], "The ad was successfully added.");
$this->ads->setIniVal('ad' . $highest, "int", $int);
$this->ads->setIniVal('ad' . $highest, "chan", $channel);
$this->ads->setIniVal('ad' . $highest, "msg", $ad);
$this->ads->writeIni();
}
}
}
}
}
public function priv_admin($line, $args)
{
if ($args['nargs'] < 2)
{
return;
}
if ($this->ircClass->getClientConf('dccadminpass') == "")
{
return;
}
if (md5($args['arg1']) != $this->ircClass->getClientConf('dccadminpass'))
{
return;
}
$query = substr($args['query'], strlen($args['arg1']) + 1);
$myArgs = parser::createLine($query);
switch ($args['arg2'])
{
case "chatme":
$port = $this->dccClass->addChat($line['fromNick'], null, null, true, null);
if ($port === false)
{
$this->ircClass->notice($line['fromNick'], "Error starting chat, please try again.", 1);
}
break;
default:
$chat = new chat_wrapper($line['fromNick'], $this->ircClass);
$cmdList = $this->parserClass->getCmdList();
$cmdLower = $myArgs['cmd'];
if (isset($cmdList['dcc'][$cmdLower]))
{
if ($myArgs['nargs'] < $cmdList['dcc'][$cmdLower]['numArgs'])
{
$chat->dccSend("Usage: " . $cmdLower . " " . $cmdList['dcc'][$cmdLower]['usage']);
break;
}
$module = $cmdList['dcc'][$cmdLower]['module'];
$class = $cmdList['file'][$module]['class'];
$func = $cmdList['dcc'][$cmdLower]['function'];
$class->$func($chat, $myArgs);
$chat->dccSend("ADMIN " . irc::myStrToUpper($cmdLower) . " Requested");
}
else
{
$chat->dccSend("Invalid Command: " . $myArgs['cmd']);
}
break;
}
}
}
?>

View file

@ -0,0 +1,21 @@
file lw_mod modules/lw/lw_mod.php
priv !r true false false 0 lw_mod getRank
priv !rank true false false 0 lw_mod getRank
priv !civ true false false 0 lw_mod getCivRank
priv !mil true false false 0 lw_mod getMilRank
priv !fin true false false 0 lw_mod getFinRank
priv !idr true false false 0 lw_mod getIDR
priv !a true false false 0 lw_mod getAllianceRank
priv !arank true false false 0 lw_mod getAllianceRank
priv !t true false false 0 lw_mod nextTick
priv !tick true false false 0 lw_mod nextTick
priv !g true false false 0 lw_mod listGames
priv !games true false false 0 lw_mod listGames
priv !h true false false 0 lw_mod help
priv !help true false false 0 lw_mod help

View file

@ -0,0 +1,438 @@
<?php
class lw_mod extends module {
public function init() {
}
public function destroy() {
}
public function nextTick($line, $args) {
$gameID = $args['nargs'] == 1 ? $args['query'] : null;
// Get the game
$game = is_null($gameID) ? config::getDefaultGame() : config::getGame($gameID);
if (is_null($game)) {
$msg = "Game ID '" . BOLD . $gameID . BOLD . "' not found";
} else {
// Try finding public ticks
$minTick = null;
foreach ($game->ticks as $tick) {
if (! $tick->definition->public) {
continue;
}
$tick->computeNext();
if (is_null($tick->next)) {
continue;
}
if (is_null($minTick) || $minTick->next > $tick->next) {
$minTick = $tick;
}
}
if (is_null($minTick)) {
$msg = "[" . BOLD . $game->text . BOLD . "] No more ticks on this game";
} else {
$msg = "[" . BOLD . $game->text . BOLD . "] Next tick: " . BOLD
. $minTick->definition->getName('en') . BOLD . " at " . BOLD
. gmstrftime("%H:%M:%S", $minTick->next) . BOLD;
if (gmstrftime("%Y-%m-%d", $minTick->next) != gmstrftime("%Y-%m-%d", time())) {
$msg .= " on " . BOLD . gmstrftime("%d/%m/%Y", $minTick->next) . BOLD;
}
}
}
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function listGames($line, $args) {
static $statusText = array(
"READY" => "open for registration",
"RUNNING" => "running",
"VICTORY" => "victory conditions reached",
"ENDING" => "being terminated",
"FINISHED" => "terminated"
);
$to = $line['fromNick'];
dbConnect();
foreach (config::getGames() as $game) {
if ($game->name == 'main' || $game->status() == 'PRE') {
continue;
}
$msg = "(" . BOLD . $game->name . BOLD . ") " . BOLD . $game->text . BOLD . " - Status: "
. BOLD . $statusText[$game->status()] . BOLD;
if ($game->status() == "READY") {
$msg .= " - Starting at " . BOLD . gmstrftime("%H:%M:%S", $game->firstTick())
. BOLD . " on " . BOLD . gmstrftime("%d/%m/%Y", $game->firstTick()) . BOLD;
} elseif ($game->status() == "ENDING") {
$msg .= " - Ending at " . BOLD . gmstrftime("%H:%M:%S", $game->lastTick())
. BOLD . " on " . BOLD . gmstrftime("%d/%m/%Y", $game->lastTick()) . BOLD;
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
}
public function getRank($line, $args) {
list($player, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchGenRank($player, $game);
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Player " . BOLD . $player . BOLD
. ": " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
if (! is_null($rv[2])) {
$msg .= " - Overall round ranking: " . BOLD . "#{$rv[2]['ranking']}"
. BOLD . " (" . BOLD . number_format($rv[2]['points'])
. BOLD . " points)";
}
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Player " . BOLD . $player . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function getCivRank($line, $args) {
list($player, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchDetRank($player, $game, 'p_civ');
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Player " . BOLD . $player . BOLD
. " (civilisation): " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Player " . BOLD . $player . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function getFinRank($line, $args) {
list($player, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchDetRank($player, $game, 'p_financial');
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Player " . BOLD . $player . BOLD
. " (financial): " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Player " . BOLD . $player . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function getMilRank($line, $args) {
list($player, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchDetRank($player, $game, 'p_military');
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Player " . BOLD . $player . BOLD
. " (military): " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Player " . BOLD . $player . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function getIDR($line, $args) {
list($player, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchDetRank($player, $game, 'p_idr');
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Player " . BOLD . $player . BOLD
. " (inflicted damage): " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Player " . BOLD . $player . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
private function getParams($line, $args) {
if ($args['nargs'] == 0) {
$player = $line['fromNick'];
$game = null;
} else {
$query = explode(' ', trim(preg_replace('/\s+/', ' ', $args['query'])));
if (preg_match('/^{[a-z0-9]+}$/', $query[0], $matches)) {
$game = preg_replace('/[{}]/', '', array_shift($query));
} else {
$game = null;
}
$player = join(' ', $query);
if ($player == '') {
$player = $line['fromNick'];
}
}
return array($player, $game);
}
private function fetchGenRank($player, $gameID) {
// Get the game
$game = is_null($gameID) ? config::getDefaultGame() : config::getGame($gameID);
if (is_null($game)) {
return 1;
}
// Access the rankings library
$rLib = $game->getLib('main/rankings');
// Get player ranking
$rType = $rLib->call('getType', 'p_general');
$genRank = $rLib->call('get', $rType, $player);
if (is_null($genRank['points'])) {
return 2;
}
// Try getting the overall round rankings
$rType = $rLib->call('getType', 'p_round');
$orRank = $rLib->call('get', $rType, $player);
if (is_null($orRank['points'])) {
$orRank = null;
}
return array($game->text, $genRank, $orRank);
}
private function fetchDetRank($player, $gameID, $type) {
// Get the game
$game = is_null($gameID) ? config::getDefaultGame() : config::getGame($gameID);
if (is_null($game)) {
return 1;
}
// Access the rankings library
$rLib = $game->getLib('main/rankings');
// Get player ranking
$rType = $rLib->call('getType', $type);
$rank = $rLib->call('get', $rType, $player);
if (is_null($rank['points'])) {
return 2;
}
return array($game->text, $rank);
}
public function getAllianceRank($line, $args) {
list($alliance, $game) = $this->getParams($line, $args);
dbConnect();
$rv = $this->fetchDetRank($alliance, $game, 'a_general');
dbClose();
if ($line['to'] == $this->ircClass->getClientConf('nick')) {
$to = $line['fromNick'];
} else {
$to = $line['to'];
}
if (is_array($rv)) {
$msg = "[" . BOLD . $rv[0] . BOLD . "] Alliance " . BOLD . $alliance . BOLD
. ": " . BOLD . "#{$rv[1]['ranking']}" . BOLD . " (" . BOLD
. number_format($rv[1]['points']) . BOLD . " points)";
} elseif ($rv == 1) {
$msg = "Game ID '" . BOLD . $game . BOLD . "' not found";
} elseif ($rv == 2) {
$msg = "Alliance " . BOLD . $alliance . BOLD . " not found";
}
$this->ircClass->sendRaw("PRIVMSG $to :$msg");
}
public function help($line, $args) {
$help = array(
"" => array(
"This bot allows you to get some information from the",
"Legacy Worlds game directly here, on IRC!",
" ",
"You can use any of the following commands:",
" ",
" " . BOLD . "Displaying rankings" . BOLD,
" " . BOLD . "rank" . BOLD . " - displays players' general and round rankings",
" " . BOLD . "civ" . BOLD . " - displays players' civilian rankings",
" " . BOLD . "mil" . BOLD . " - displays players' military rankings",
" " . BOLD . "fin" . BOLD . " - displays players' financial rankings",
" " . BOLD . "idr" . BOLD . " - displays players' inflicted damage rankings",
" " . BOLD . "arank" . BOLD . " - displays alliances' rankings",
" ",
" " . BOLD . "General information" . BOLD,
" " . BOLD . "games" . BOLD . " - lists available games",
" " . BOLD . "tick" . BOLD . " - displays the time and date of the next tick",
" " . BOLD . "help" . BOLD . " - help access",
" ",
"All commands must start with the '!' character. To get more",
"information on a specific command, type '!help <command>'"
),
"arank" => array(
"Syntax: " . BOLD . "!arank [{game}] tag",
" " . BOLD . "!a [{game}] tag",
" ",
"This command gives information about an alliance's ranking.",
" ",
"It is possible to select the game by adding the game's ID between",
"brackets just before the player's name.",
),
"rank" => array(
"Syntax: " . BOLD . "!rank [{game}] [player]",
" " . BOLD . "!r [{game}] [player]",
" ",
"This command gives information about a player's general ranking",
"as well as his round ranking if he has one.",
" ",
"Using the command without parameters will cause the bot to look",
"for your current nick, if it's the same as your in-game name.",
" ",
"It is possible to select the game by adding the game's ID between",
"brackets just before the player's name.",
" ",
"Examples: !r TSeeker",
" -> Displays TSeeker's rankings in the default game",
" !r {b5m2}",
" -> Displays your rankings in Match 2",
),
"civ" => array(
"Syntax: " . BOLD . "!civ [{game}] [player]",
" ",
"This command gives information about a player's civilisation",
"ranking.",
" ",
"Using the command without parameters will cause the bot to look",
"for your current nick, if it's the same as your in-game name.",
" ",
"It is possible to select the game by adding the game's ID between",
"brackets just before the player's name.",
" ",
"See also: " . BOLD . "!help rank" . BOLD
),
"mil" => array(
"Syntax: " . BOLD . "!mil [{game}] [player]",
" ",
"This command gives information about a player's military",
"ranking.",
" ",
"Using the command without parameters will cause the bot to look",
"for your current nick, if it's the same as your in-game name.",
" ",
"It is possible to select the game by adding the game's ID between",
"brackets just before the player's name.",
" ",
"See also: " . BOLD . "!help rank" . BOLD
),
"fin" => array(
"Syntax: " . BOLD . "!fin [{game}] [player]",
" ",
"This command gives information about a player's financial",
"ranking.",
" ",
"Using the command without parameters will cause the bot to look",
"for your current nick, if it's the same as your in-game name.",
" ",
"It is possible to select the game by adding the game's ID between",
"brackets just before the player's name.",
" ",
"See also: " . BOLD . "!help rank" . BOLD
),
"tick" => array(
"Syntax: " . BOLD . "!tick [game]",
" " . BOLD . "!t [game]",
" ",
"This command displays the next tick.",
" ",
"It is possible to select the game by adding the game's ID",
"after the command.",
),
"games" => array(
"Syntax: " . BOLD . "!games",
" " . BOLD . "!g",
" ",
"This command displays the list of available games.",
),
);
$topic = $args['query'];
if (! array_key_exists($topic, $help)) {
$topic = "";
}
$to = $line['fromNick'];
for ($i = 0; $i < count($help[$topic]); $i ++) {
$this->ircClass->privMsg($to, $help[$topic][$i]);
}
}
}
?>

View file

@ -0,0 +1 @@
For More Modules, see the website: http://www.phpbots.org

View file

@ -0,0 +1,11 @@
file seen_mod modules/seen/seen_mod.php
privmsg seen_mod seen
;notice seen_mod seen
join seen_mod seen
kick seen_mod seen
part seen_mod seen
quit seen_mod seen
priv !seen true true true 0 seen_mod priv_seen

View file

@ -0,0 +1,234 @@
<?php
/*
+---------------------------------------------------------------------------
| PHP-IRC v2.2.0
| ========================================================
| by Manick
| (c) 2001-2005 by http://phpbots.sf.net/
| Contact: manick@manekian.com
| irc: #manekian@irc.rizon.net
| ========================================
+---------------------------------------------------------------------------
| > Seen Mod
| > Module written by Manick
| > Module Version Number: 0.1
+---------------------------------------------------------------------------
| > This program is free software; you can redistribute it and/or
| > modify it under the terms of the GNU General Public License
| > as published by the Free Software Foundation; either version 2
| > of the License, or (at your option) any later version.
| >
| > This program is distributed in the hope that it will be useful,
| > but WITHOUT ANY WARRANTY; without even the implied warranty of
| > MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| > GNU General Public License for more details.
| >
| > You should have received a copy of the GNU General Public License
| > along with this program; if not, write to the Free Software
| > Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+---------------------------------------------------------------------------
| Changes
| =======-------
| > If you wish to suggest or submit an update/change to the source
| > code, email me at manick@manekian.com with the change, and I
| > will look to adding it in as soon as I can.
+---------------------------------------------------------------------------
*/
class seen_mod extends module {
public $title = "Seen Mod";
public $author = "Manick";
public $version = "0.1";
private $seen;
public function init()
{
$this->timerClass->addTimer("seen_mod_updateini", $this, "seen_update", "", 60*15, false);
$this->seen = new ini("modules/seen/seen.ini");
}
public function destroy()
{
$this->timerClass->removeTimer("seen_mod_updateini");
}
// Write to file
public function seen_update($args)
{
if ($this->seen->getError())
{
return;
}
$this->seen->writeIni();
$this->dccClass->dccSend("Updated Seen Mod ini database file");
return true;
}
// Update actions
public function seen($line, $args)
{
if ($this->seen->getError())
{
if (DEBUG == 1)
{
echo "Seen error!\n";
}
return;
}
if (strtolower($line['cmd']) == "join")
{
$line['text'] = "";
}
if (strtolower($line['cmd']) == "kick")
{
$offsetA = strpos($line['params'], chr(32));
$act = "kick";
$user = substr($line['params'], $offsetA + 1);
$this->addLast($user, $act, $line['text']);
}
else
{
$this->addLast($line['fromNick'], strtolower($line['cmd']), $line['text']);
}
$this->getLast($line['fromNick']);
}
private function getLast($user)
{
$user = irc::myStrToLower($user);
if (!$this->seen->sectionExists("seen"))
{
return;
}
$var = $this->seen->getIniVal("seen", $user);
if ($var == false)
{
return false;
}
$offsetA = strpos($var, "=");
$offsetB = strpos($var, "=", $offsetA + 1);
$offsetC = strpos($var, "=", $offsetB + 1);
$info = array();
$info['user'] = substr($var, 0, $offsetA);
$info['time'] = substr($var, $offsetA + 1, $offsetB - $offsetA - 1);
$info['act'] = substr($var, $offsetB + 1, $offsetC - $offsetB - 1);
$info['txt'] = substr($var, $offsetC + 1);
return $info;
}
private function addLast($user, $act, $txt)
{
$Suser = irc::myStrToLower($user);
$tAction = $user . "=" . time() . "=" . irc::myStrToLower($act) . "=" . $txt;
$this->seen->setIniVal("seen", $Suser, $tAction);
}
// User interface
public function priv_seen($line, $args)
{
if ($this->seen->getError())
{
$this->ircClass->notice($line['fromNick'], "There was an error while attempting to access the seen database.");
return;
}
if ($line['to'] == $this->ircClass->getNick())
{
return;
}
if ($args['nargs'] <= 0)
{
$this->ircClass->notice($line['fromNick'], "Usage: !seen <nick>");
return;
}
$user = irc::myStrToLower($args['arg1']);
if ($user == irc::myStrToLower($line['fromNick']))
{
$this->ircClass->privMsg($line['to'], $line['fromNick'] . ", umm... O..kay...");
$this->ircClass->action($line['to'], "points at " . $line['fromNick'] . "...");
return;
}
$data = $this->getLast($user);
if ($data === false)
{
$this->ircClass->privMsg($line['to'], $line['fromNick'] . ", I have never seen " . $args['arg1'] . " before.");
return;
}
$time = time() - $data['time'];
if ($time > 3600*24)
{
$timeString = irc::timeFormat($time, "%d days %h hours %m min %s sec");
}
else if ($time > 3600)
{
$timeString = irc::timeFormat($time, "%h hours %m min %s sec");
}
else if ($time > 60)
{
$timeString = irc::timeFormat($time, "%m min %s sec");
}
else
{
$timeString = irc::timeFormat($time, "%s sec");
}
$action = "";
switch ($data['act'])
{
case "privmsg":
$action = "saying in a channel";
break;
case "notice":
$action = "noticing a channel";
break;
case "join":
$action = "joining a channel";
break;
case "kick":
$action = "being kicked from a channel";
break;
case "part":
$action = "parting a channel";
break;
case "quit":
$action = "quitting";
break;
}
if ($data['txt'] != "")
{
$action .= ": " . $data['txt'];
}
$this->ircClass->privMsg($line['to'], $line['fromNick'] . ", I last saw " . $data['user'] . " " . $timeString . " ago " . $action . ".");
}
}
?>

View file

@ -0,0 +1,39 @@
<?php
/*
Change:
'class_name' to the name of your module (specified in function.conf)
Add:
Your functions after "//Methods here:"
Add:
Timer declarations and other general startup stuff to be run when the bot starts up in the init() function
*/
class class_name extends module {
public $title = "<title>";
public $author = "<author>";
public $version = "<version>";
public function init()
{
// Add your timer declarations and whatever
// else here...
}
public function destroy()
{
// Put code here to destroy the timers that you created in init()
// and whatever else cleanup code you want.
}
//Methods here:
}
?>