I had added a few things to my IRC module in .2 but can't seem to get them working in .3.4 so thought I'd see what you guys think. I'm sure its just something with the way .3.x handles stuff differently. I changed the !online to show difference in org chat and private group and added a whois.
/*
* Gets called when someone does !online
*/
function irc_online(&$irc, &$data)
{
if (isset($this -> bot -> commands["tell"]["online"]))
{
foreach($this -> bot -> commands["tell"]["online"] -> guild as $player)
$nick[$player[0]] = 1;
ksort($nick);
$msg = count($nick) . " org members online: ";
foreach ($nick as $name => $val)
$msg .= $name . ", ";
foreach($this -> bot -> commands["tell"]["online"] -> pgroup as $guestplayer)
$guestnick[$guestplayer[0]] = 1;
ksort($guestnick);
$guestmsg = count($guestnick) . " players in guest channel: ";
foreach ($guestnick as $guestname => $val)
$guestmsg .= $guestname . ", ";
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, $msg);
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, $guestmsg);
}
else
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, "Online module not installed.");
}
/*
* Whois Function - Used exclusively for IRC to strip color codes and add IRC specific coding
*/
function whois_player($name)
{
$content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
$who["nick"] = $this -> bot -> xmlparse($content, "nick");
$who["firstname"] = $this -> bot -> xmlparse($content, "firstname");
$who["lastname"] = $this -> bot -> xmlparse($content, "lastname");
$who["level"] = $this -> bot -> xmlparse($content, "level");
$who["gender"] = $this -> bot -> xmlparse($content, "gender");
$who["breed"] = $this -> bot -> xmlparse($content, "breed");
$who["profession"] = $this -> bot -> xmlparse($content, "profession");
$who["faction"] = $this -> bot -> xmlparse($content, "faction");
$who["rank"] = $this -> bot -> xmlparse($content, "rank");
$who["org"] = $this -> bot -> xmlparse($content, "organization_name");
$who["at_name"] = $this -> bot -> xmlparse($content, "defender_rank");
$who["at"] = $this -> bot -> xmlparse($content, "defender_rank_id");
if (!empty($who["nick"]))
{
$at = "(AT " . $who["at"] . " - " . $who["at_name"] . ") ";
$result = "\"" . $who["nick"] . "\"";
if (!empty($who["firstname"]) && ($who["firstname"] != "Unknown"))
$result = $who["firstname"] . " " . $result;
if (!empty($who["lastname"]) && ($who["lastname"] != "Unknown"))
$result .= " " . $who["lastname"];
$result .= " is a level " . $who["level"] . " " . $at . $who["gender"] . " " . $who["breed"] . " " . $who["profession"] . ", " . $who["faction"];
if (!empty($who["rank"]))
$result .= ", " . $who["rank"] . " of " . $who["org"] . ".";
else
$result .= ".";
}
else
$result = "www.anarchy-online.com was too slow to respond.";
return $result;
}
/*
* Gets called when someone does !whois
*/
function irc_whois(&$irc, &$data)
{
if (isset($this -> bot -> commands["tell"]["whois"]))
{
preg_match("/^" . $this -> bot -> commpre . "whois (.+)$/i", $data -> message, $info);
$info[1] = ucfirst(strtolower($info[1]));
if ($this -> bot -> aoc -> get_uid($info[1]))
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, $this -> whois_player($info[1]));
else
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, "Player " . $info[1] . " does not exist.");
}
else
$this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, "Whois module not installed.");
}