BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: myste on March 06, 2006, 11:35:28 pm

Title: IGN Relay
Post by: myste on March 06, 2006, 11:35:28 pm
ok so i got a bit bored, and hacked IGN bot relay into BeBot tonight.. currently works only with one IGN bot at a time, and requieres changing the core of the bot slightly... :( (at least with my less than perfect knowledge of the bebot and IGN)

Gonna change it to use the settings system i think, or perhaps make the configuration in a separate table.. at the moment its a combination of the .conf file and hardcoded values.

Anyone interested or should i just keep it to myself?

Title: Re: IGN Relay
Post by: Tsuyoi on March 11, 2006, 05:17:50 pm
I'd love to see it.  This is the only thing holding me back from switching my guilds bot from IGN to Bebot as we have afew guilds on relay-chat and would miss out on that.

- Tsuyoi
Title: Re: IGN Relay
Post by: myste on March 12, 2006, 12:19:48 am
Roger that.. ive been hacking away some more.. currently got multiple bots configurable through the database up and running.

This "patch" consists of 3 parts.

1) Changes to the core of the bot itself. (see code below)
2) A module/plugin for handling IGN bot relays IGN_Relay_GUILD.
3) An admin module/plugin for handling the DB settings the IGN (and other future implementations) should look for, relay_adm.

Still things to fix and implement, but here is the current version.


Code changes to bot.php:


Insert the following near the top of the function "connect()":
Code: [Select]
// Make sure the relaybots table exists
$this -> db -> query("CREATE TABLE IF NOT EXISTS relaybots
(id int(11) NOT NULL PRIMARY KEY,
botname VARCHAR(25),
prefix varchar(10),
protocol varchar(10))");


Add the following function in bot.php:
Code: [Select]
/*
Check if person actually is a relay bot we are using
*/
function is_relaybot($uname)
{
$result = $this -> db -> select("SELECT botname, protocol FROM relaybots WHERE id = " . $this -> aoc -> get_uid($uname));
if (!empty($result))
{
return $result[0][1];
}
return false;
}


REPLACE the "inc_tell()" function with this implementation:
Code: [Select]
/*
Incomeing Tell
*/
function inc_tell($args)
{
if (!preg_match("/is AFK .Away from keyboard./i", $args[1]) && !preg_match("/.tell (.+)help/i",$args[1]) && !preg_match("/I only listen to members of this bot/i",$args[1] ))
{
$user = $this -> aoc -> get_uname($args[0]);
$found = false;

$args[1] = utf8_decode($args[1]);

if (preg_match("/<a type=chatclient version=(.+) href=(.+)>/isU", $args[1], $info))
{
if (isset($this -> commands["tell"]["online"]))
$this -> commands["tell"]["online"] -> chatclient ($user[0], $info[2]);
$args[1] = preg_replace("/<a type=chatclient version=(.+) href=(.+)><\/a>/isU", "", $args[1]);
}

$this -> log("TELL", "INC", $user . ": " . $args[1]);

if (!isset($this -> other_bots[$user]))
{
if ($protocol = $this -> is_relaybot($user))
{
// Treats relaybots special, dont requiere <pre> (for IGN support).
if (!empty($this -> commands["relay"]))
{
$this -> log("RELAY", "INC", "[$protocol]\t" . $user . ": " . $args[1]);
$comms = array_keys($this -> commands["relay"]);
for ($i = 0; $i < count($comms); $i++)
{
if ($comms[$i] == $protocol)
{
$this -> commands["relay"][$protocol] -> relay ($user, $args[1]);
$i = count($comms);
$found = true;
}
}
}
}
else if ($this -> is_member($user))
{
if (!empty($this -> commands["tell"]))
{
$comms = array_keys($this -> commands["tell"]);
for ($i = 0; $i < count($comms); $i++)
{
if ($this -> is_command($comms[$i], $args[1]) && $this -> rightsmanagement -> check_rights($user, $comms[$i], "tell"))
{
$this -> commands["tell"][$comms[$i]] -> tell ($user, $args[1]);
$i = count($comms);
$found = true;
}
}
}
}
else
{
if (!empty($this -> commands["tell2"]))
{
$comms = array_keys($this -> commands["tell2"]);
for ($i = 0; $i < count($comms); $i++)
{
if ($this -> is_command($comms[$i], $args[1]) && $this -> rightsmanagement -> check_rights($user, $comms[$i], "tell2"))
{
$this -> commands["tell2"][$comms[$i]] -> tell2 ($user, $args[1]);
$i = count($comms);
$found = true;
}
}
}
}

if (!$found)
{
if ($this -> is_relaybot($user))
{
// Do nothing.. bots dont need help
}
else if ($this -> is_member($user))
{
$this -> send_help($args[0]);
}
else if ($this -> guild_bot)
{
$this -> send_tell($args[0], "I only listen to members of " . $this -> guildname . ".");
}
else
{
$this -> send_tell($args[0], "I only listen to members of this bot.");
}
}
}
}
}


So what does the changes to the core do? Well it adds a new type of callback registration keyword based on the PROTOCOL the implementation is using (not the name of the command).

If you look at the top of the IGN_Relay_GUILD.php you will see:
Code: [Select]
$commands["relay"]["IGN"] = &$ignrelay;
This registers the object (ignrelay) to receive "tells" from registered IGN bots to its "relay()" function. (not its tell function)

I was considering for a long time to call it "raw" instead of "relay" but since im using the protocol as part of the filtering in the core i thought it more describing.
If anyone has a better way of doing this I would love to hear of it, but im a n00b at BeBot so I hacked it like i saw it ;)
Title: Re: IGN Relay
Post by: myste on March 12, 2006, 12:26:10 am
So here is how to actually USE it after you have installed it. The menu system of the adm interface is NOT complete, so here is the commands you execute in a tell to your bot:

Code: [Select]
!botrelay add bot:name_of_bot prefix:one_or_more_characters proto:IGN
That adds the bot as an IGN bot to the database, and informs you new bot-core to lett messages from the IGN bot through to the relay implementation.

After this you do the following:

Code: [Select]
!ignrelay on
That will tell the IGN plugin to start connecting to the bots registered, and start looking for that prefix in your guild chat.


PS! Remember to do a "connect" or whetever it is called on your IGN bot as well to register your bebot on the IGN network.
Title: Re: IGN Relay
Post by: Dabaron on August 18, 2006, 01:07:41 am
Has anyone gotten this to work right?  I get an error in the IGN_Relay_Guild module.  If anyone has I will run it all again and get the error and everything, if not I will have to try and find another solution I suppose ;)
Title: Re: IGN Relay
Post by: Dabaron on August 22, 2006, 06:58:06 pm
Ok, I got it working fine.  Only issue I have is it dosen't relay to private group, only guild chat.  Any ideas?
Title: Re: IGN Relay
Post by: Alreadythere on August 22, 2006, 11:06:32 pm
Not sure where it does $this -> send_gc($relayed_text), and too tired to look over the code for it.
But after that line add a $this -> send_pgmsg($relayed_text), that's all.
Title: Re: IGN Relay
Post by: Dabaron on August 22, 2006, 11:15:08 pm
I'm guessing thats in the IGN_Relay_GUILD.php file and is the line that says  $this -> bot -> send_gc($info[1]);

Only place I can see that even remotely looks like it.  I new it would be a simple adding of the send_pgmsg but wasn't sure if anyone knew exactly what spot to add that on.  I'll test it a bit.
Title: Re: IGN Relay
Post by: Dabaron on August 24, 2006, 08:49:49 am
Ok, that did work.  My last thing I'm trying to accomplish with this is for the relay to work from the guest channel as well.  I can now recieve them from guest chat, but can't send to other bots from there.  I was guessing that in the function relay_connect() where it has:
 
Code: [Select]
$this -> bot -> commands["gmsg"][$this -> bot -> guildname]["ignrelay"] = &$this;
is what is making it listen to org chat so I added:

Code: [Select]
$this -> bot -> commands["pgroup"][$this -> bot -> guildname]["ignrelay"] = &$this;
That didn't work so I added:
Code: [Select]
$commands["pgroup"]["ignrelay"] = &$ignrelay;
Then I copied the function gmsg part and made another function called pgroup with same info and also didn't do the trick.  Anyone have any other ideas?
Title: Re: IGN Relay
Post by: Alreadythere on August 24, 2006, 11:56:04 am
Check out the chat relay (http://svn.shadow-realm.org/index.py/BeBot/trunk/modules/Relay_GUILD.php?view=markup) between org chat and guest channel, especially the start_relay() function.
Title: Re: IGN Relay
Post by: nebhyper on November 28, 2006, 05:36:47 pm
So...  does this work like IGN works?


I mean, can you connect say 8 bots to each other and they only send each other stuff when someone uses @?

I ask because my org will not leave IGN unless we can keep our connection between our friend orgs. 

Perhaps this is apart of 0.2.9 and I missed it?  Or it will be in 0.3.x?

Title: Re: IGN Relay
Post by: Naturalistic on November 28, 2006, 06:04:25 pm
You need to do quite a bit of configuring of the bots, but yes, it's possible.

At one time I had 5 bots using @ to talk to each one ;)

Just requires (if I recall):
- names in the config or a database table to "accept" other bots.
- mod the relay to your liking (sending pgroup, or guild only etc)

There might be other steps, I just can't remember exactly all of them. Maybe that would give some ideas :P
Title: Re: IGN Relay
Post by: nebhyper on December 03, 2006, 06:31:21 am
Well thanks for the info.  But it does not work fo rme.
Everytime I try to do add a bot it gives me this error:

Fatal error: Call to a member function check_rights() on a non-object in C:\[edited out file path]\Bot.php on line 425


ANy ideas?
Title: Re: IGN Relay
Post by: neongen on December 03, 2006, 09:56:08 pm
oki i have worked around the check_rights part but i can't get it to work... it will not connect to a bebot only ignbot... and i get a lot of problems with the foreach () on line 287 and on line 59

line 287 = foreach ($this -> prefix as $botname => $prefix)

line 59 = foreach($rows as $row)

anyone know why?
Title: Re: IGN Relay
Post by: nebhyper on December 03, 2006, 11:26:26 pm
I'm still stuck on why check_rights() is giving me issues
Title: Re: IGN Relay
Post by: neongen on December 05, 2006, 12:17:35 am
try and look at this http://bebot.link/index.php/topic,153.0.html (http://bebot.link/index.php/topic,153.0.html) nebhyper
Title: Re: IGN Relay
Post by: nebhyper on December 06, 2006, 06:24:13 am
Everytime I do !ignrelay on   it spams all the bots I'm connecting to with:

[IGN Gridnet] authorized connection established with: United Notum Federation


Anyway to avoid that?  I mean an IGN bot booting up auto connects and does not cause that spam.


Also, speaking of booting up, anyway to automate !ignrelay on when the bot starts?

thanks
Title: Re: IGN Relay
Post by: nebhyper on December 07, 2006, 10:27:49 pm
I'm trying to stop my bot from spamming all the IGN bots it's connected to with the ignsend on comamnd.

Since those bots are set up to accept my bots name anyway, I start digging thru the code to see if I could stop this as ignsend on is not needed everytime the bot restarts.

So, I added a function to the IGN_Relay_GUILD.php and a call to it from bot.php on start up. 

This function merely sets the state of each IGN bot in my database to "Online" and sets the prefix to be listened to for relaying. 

Below is what I added.

IGN_Relay_GUILD.php
Code: [Select]
function relay_auto()
{
// Starts listening to guild chat
$this -> bot -> log("IGNRELAY", "CONNECTION", "Connecting to bots");
        $this -> bot -> commands["gmsg"][$this -> bot -> guildname]["ignrelay"] = &$this;
$this -> bot -> log("IGNRELAY", "CONNECTION", "Listening to prefix");

// List all bots as connected
$rows = $this -> bot -> db -> select("SELECT botname, prefix FROM relaybots WHERE protocol = \"IGN\"");
foreach($rows as $row)
{
$botname = ucfirst(strtolower($row[0]));
$this -> prefix[$botname] = $row[1];
$this -> state[$botname] = "online";
$this -> bot -> log("IGNRELAY", "CONNECTION", "Connected to $botname.");

}
}

added to bot.php at the end of function connect()
Code: [Select]
$this -> commands["relay"]["IGN"] -> relay_auto ();

I can not test this right now, and before I try to test it can someone look it over and see if this will work?

Goal is to set each bot I connect to, to "Online" state and to get the bot to listen to the prefix without spamming the request to connect (ignsend on ) command to each bot.  This is based on the premise that each bot is already setup and expecting to listen for my bot. (If that makes sense.)

Thanks in advance
Title: Re: IGN Relay
Post by: Dream on January 01, 2007, 05:50:19 pm
Well after much modification and tweaking of the Bot.php file, I now have what appears to be a functional version of the guild relay.

Well, functional in that it will relay fine, however the only problem I'm having is with IGN bots.

They're not sending "transmit xxxxxxx" in tells.

I put tracers in the IGN code, and its sending via its relay_packet($packets) function ... not via its send_packets($packets) function.

it send the messages out, as other IGN bots pick them up ... but there's no sign of a tell being sent out for BeBot code to pick up!

Any help on where I can catch hold of the sent out IGN messages would be greatly appreciated!

Peace,
Dream.
SimplePortal 2.3.7 © 2008-2025, SimplePortal