BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Naturalistic on December 11, 2005, 02:36:31 am

Title: Org Event chat notification
Post by: Naturalistic on December 11, 2005, 02:36:31 am
Just something I thought I'd share. Not the greatest, any ideas are welcomed. :) Hope you enjoy it.

P.S. Make sure to have updated the AOChat.php and whatnot. Any issues/problems with it, please also leave a msg.

Code: [Select]
<?php

  
/*
   * OrgEvent.php - Handles Org join/leave/kick events.
   *
   * Written by Naturalistic for the BeBot (Guild version) bot.
   *
   * Really simple, variables aren't the greatest thoughtup but it's what you get with lack of sleep ;)
   */

$orgevent = new orgevent($bot);

$commands['gmsg']['Org. Msg.'][] = &$orgevent;

class 
orgevent 
{
    var 
$bot;

function orgevent(&$bot)
{
$this -> bot = &$bot;
}

function gmsg($name$group$msg
{
if ($name == "0")
{
if (preg_match("/(.+) kicked (.+) from your organization./i"$msg$info))
{
$personkicked $info[2];
$kicker $info[1];
$this -> bot -> send_gc("<font color=#ffff00>$personkicked</font> was kicked from the org by $kicker!");
} else if (preg_match("/(.+) has left your organization./i"$msg$info)) 
{
$person $info[1];
$this -> bot -> send_gc("<font color=#ffff00>$person</font> has left the org!");
} else if (preg_match("/(.+) has joined your organization./i"$msg$info))
{
$person $info[1];
$this -> bot -> send_gc("<font color=#ffff00>$person</font> has just joined the org!");
}
}
}
}
?>

Title: Re: Org Event chat notification
Post by: Naturalistic on December 18, 2005, 02:25:32 am
Bump

Fix for a minor chat misread on my part (thanks akarah for pointing it out :) )

Code: [Select]
else if (preg_match("/(.+) just left your organization./i", $msg, $info))
should be:

Code: [Select]
else if (preg_match("/(.+) has left your organization./i", $msg, $info))
Title: Re: Org Event chat notification
Post by: Wolfbiter on December 18, 2005, 12:59:42 pm
Some suggested additional stuff...
This goes into the has "joined the organization" part.
Code: [Select]
$this->bot->log("Members","Add","Adding new member: $info[1]");
$whois = $this->whois($info[1]);
$this->bot->db->query("INSERT into members (nickname,level,aleve,profession,rank_name) VALUES ('".$info[1]."',".$whois[1].",".$whois[2].",'".$whois[3]."','newMember')");
$this->bot->send_gc("<font color=#ffff00>$info[1]</font> (<font color=#00CC00>$whois[1]</font> / <font color=#008800>$whois[2]</font> <font color=#10a5e5>$whois[3]</font>) just joined the organization.");
$uid = $this->bot->get_uid($info[1]);
$this->bot->aoc->buddy_add($uid);
It'll add them to the buddylist and also into the members database.

And this is the whois function
Code: [Select]
function whois($name) {
        $content = $this -> bot -> get_site("http://www.anarchy-online.com/character/bio/d/" . $this -> bot -> dimension . "/name/" . strtolower($name) . "/bio.xml");
        $result[0] = $name;
        $result[1] = $this -> bot -> xmlparse($content, "level");
        $result[2] = $this -> bot -> xmlparse($content, "defender_rank_id");
        $result[3] = $this -> bot -> xmlparse($content, "profession");
if (empty($result[1]))
$result[1] = -1;
if (empty($result[2]))
$result[1] = -1;
if (empty($result[3]))
$result[1] = "Unknown";

return $result;
    }

This is using my slightly modified roster files thou, so you should change "alevel" to whatever alien level is in your database.
Title: Re: Org Event chat notification
Post by: Akarah on December 18, 2005, 07:26:46 pm
what happens if it's a new character? i see your whois function sets it as unknown. wouldn't that insert unknowns into the member table? or would it fail due to values being negative?

i'll probably do something like this, with the WhoisCache functions though, and make sure it exists before actually inserting, etc..

i've also added a few "announcements"-- one to irc, one to guildchat, and my favorite, sending a "fine! be that way! :(" tell to someone who org leaves ;)

Title: Re: Org Event chat notification
Post by: Naturalistic on December 18, 2005, 11:16:06 pm
yeah, spam and insult them for leaving... :P
Title: Re: Org Event chat notification
Post by: Wolfbiter on December 19, 2005, 12:39:33 am
It only sets level, alien level and profession as unknown. The name is the supplied name...
Title: Re: Org Event chat notification
Post by: Akarah on December 19, 2005, 04:44:44 am
right. sorry wasn't thinking. hehe. roster update would fix it next cycle anyway.

i'll try to remember to avoid posting before i've had coffee ;)
SimplePortal 2.3.7 © 2008-2025, SimplePortal