BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Age of Conan Archive => AoC 0.6 support => Topic started by: Riccarr on May 06, 2010, 10:38:32 pm
-
Hello,
Seen numerous messages where people ask how/why doesn't the bot know when members leave the guild, and we've seen that the answer is basically because the bot does not get a message for member add/leave guild.
Several weeks ago when I added the ever popular YG command to our guild bot, it occurred to me that the YG information could be used to validate whether or not someone was still in our guild. Basically, when a person logs on, their guild name is retrieved from YG and compared to our guild name to see if they are the same.
There are a couple conditions to make sure that the comparison is not overly aggressive in identifying players as "left the guild". Mainly, I do not check unless their bot user record "added_at" is greater than "x" days old. This gives the new member time to have their profile scanned by YG and get their new guild tag (our guild) updated onto YG. You can play with an "x" days amount; I started with 2 but ended with a more conservative 5.
I also just chose to make a guild chat announcement for any online officers to see and investigate so they can determine if the "!member del" command should be used rather than coding a call to actively delete member. It's not 100% proof that the member does not belong; sometimes they take awhile to get updated in YG.
To use this technique you will need to have contacted YG to get your own account and password. Ask nicely to have access for your AoC guild usage.
Below is the code snippet I wrote; this should go into the LOGON.PHP file which is found in your MODULES folder. Sorry you will have to work it into your own module, I've made other alterations to my logon module and cannot upload the whole thing.
I located this snippet in the buddy($name, $msg) function. There may be better spot, but this works for me. Put the code at the end of the logon block, right after these two lines, they should be near line 212.
(do not add these lines, they are for reference)
$this -> show_logon("##logon_logon_spam##" . $res . "##end##");
$this -> last_log["on"][$name] = time();
After the above two lines, this is where I coded my catch for non-guilded members.
//check for players guild name; if not our guild name, then give them 2 days to get it into YG;
//if still not equal to our guild name then report it to guild chat for an officer to investigate
$playerGuildName = $this -> getPlayerGuildName($name);
$ourGuildName = $this -> bot -> core("settings") -> get("Relay", "Gcname");
if (($playerGuildName) && (strcasecmp($playerGuildName, $ourGuildName) <> 0))
{
$results = $this -> bot -> db -> select("SELECT unix_timestamp() - added_at as account_age FROM #___users where nickname = '$name' and last_seen > 0");
if (!empty($results))
{
$account_age = $results[0][0];
//seconds in days = ((24 * 60) * 60) * (# of days)
if ($account_age > (((24 * 60) * 60) * 5)) //last number represents "days", 5 in this case
{
$this -> bot -> send_gc("Player $name does not belong to this guild. Officer investigate to see if toon needs to be !member deleted");
}
}
}
This is also a supporting function you need to add into your module. I wrote this to call YG and return the guild name of the player. Its basically hacked from the YG module.
function getPlayerGuildName($name)
{
$password = 'your password here';
$servername = $this->bot->dimension;
$yg_link = "http://aoc.yg.com/profilexml?n=$name&srv=$servername&pwd=$password";
$ch = $this -> bot -> core("tools") -> get_site($yg_link, 1);
if (empty($ch["content"]))
return 0;
$xmlprf = $ch["content"];
$xmlobj = simplexml_load_string($xmlprf);
/* Done loading xml profile data */
if($xmlobj->aocygplayerprofile->name)
if($xmlobj->aocygplayerprofile->guild)
return $xmlobj->aocygplayerprofile->guild;
return 0;
}
I hope this helps as a workable solution for those growing/changing guilds with transient members.
Cheers,
Eric
-
Very nice and informative post Riccarr :)
Getrix is looking into integrating YG in several locations of the official distribution, allowing for better overall AoC functionality, but no ETA or promises on when/if it happens.
-
Nice post - using this with a little tweak :)
In getPlayerGuildName I'm using:
if($xmlobj->aocygplayerprofile->name)
if($xmlobj->aocygplayerprofile->guild)
{
return $xmlobj->aocygplayerprofile->guild;
}
else
{
return "Not in a Guild";
}
return "Not found on YG";
and for the message that gets displayed I'm using:
$this -> bot -> send_gc("*** Player $name is logged as being in Guild: ##logon_organization##$playerGuildName##end## on YG.COM - an Officer needs to check to see if this char needs to have !member del performed on it. ***");
This makes it a bit clearer as to what guild YG has them in or if it hasn't got them logged
-
I only added this block to state what guild they are in to their login message. Added at line 205.
$result = $this -> getPlayerGuildName($name);
if (!empty($result))
{
$res .= " :: ##logon_organization##$result##end##";
}
And the function posted above. Thanks for the post on this. Very useful!
~Kyr
-
Thanks guys ... glad I could contribute.
Our bebot bot has become tremendously useful and taken for granted. Its amazing sometimes the new players think its part of the game. And when its down (and I haven't gotten home from work or away for the weekend) there's always a buzz to greet me from the other players (or email) BOTS DOWN! PLZ GET IT BACK UP!
-
Awesome work ^^
This will make things easier.
And yeah, i know the feeling ^^ My mailbox get's spammed by those mails when the bot ever shuts down :P
(Not so much now, as i have it running as a service with firedaemon with webserver access to control it)
Conclusion: The bot has become an irreplaceable tool :P
-
Good work all...
I used a combination of the scripts posted above, and also connected it to YG DB...
All works well except that some members get the :
[Guild] [bot]: Player ******* does not belong to this guild. Officer investigate to see if toon needs to be !member deleted
Even though in the login info it SAYS the name of OUR guild...
I am one of them BTW, and i am OWNER of bot and LORD in guild... still it says that i dont belong to guild..?
Any idea what i have forgotten, to change in script ??..or what is wrong??
-
aoc.yg.com does not list everyone, this double check would make it a good module, people need to walk by someone who is actually scanning for YG to get listed in their DB.
-
Make sure you are using correct guildname in "!set Relay Gcname"
-
Thanx again Getrix, you are my HEROOO!!
:) ;) :D ;D >:( :( :o 8) ??? ::) :P :-[ :-X :-\ :-* :'(