Development > Coding and development discussion

Improving relay over IRC

<< < (5/6) > >>

Alreadythere:
Uhm...

No clue, it shouldn't use more memory really...

Alreadythere:
I've checked the code that I added, and besides a few instances of old settings names that I forgot to switch the only thing that could eat some memory is the regex checks. But the garbage collection should clean that up after the function calls are over...

Nytridr:

--- Quote from: Alreadythere on May 06, 2007, 08:19:16 pm ---I've checked the code that I added, and besides a few instances of old settings names that I forgot to switch the only thing that could eat some memory is the regex checks. But the garbage collection should clean that up after the function calls are over...

--- End quote ---

IDK this is like a doctor problem.. when your at home you feel sick and think you need to go to the docs.. but when you get there you feel fine and the doc says theres nothing wrong..

well guess what.. mem is stable now and even though each bot is using differnt ram ammounts they are not going up and are staying pretty stable.. even though I have seen the bot still spamming off and on.. but I am woundering  if it has something to do with what ever is going on....  the differnt org bots are using between 5meg to 15megs right now.. all differnt.. not sure why either.

Dabaron:
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.


--- Code: ---/*
* 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.");
}
--- End code ---

Alreadythere:
Online no longer stores anything in arrays, so reading the online -> guild array won't work.

You have to query the online table, like the 0.3.4 version does.

--- Code: ---$online = $this -> bot -> db -> select("SELECT nickname FROM #___online WHERE botname = '" . $this -> bot -> botname . "' AND status_gc = 1 ORDER BY nickname ASC");
--- End code ---
The $online array contains the nicknames of all online buddies then.

Replace status_gc = 1 with status_pg to get charaters in private group.

For the whois you should call $this -> bot -> whois -> lookup($name), the whois cache is integrated in 0.3.4 already. Then just adapt your output generation to the slightly different array names used in the return, check core/Whois.php for a listing. It should work otherwise.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version