collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: IGN Relay  (Read 9365 times)

0 Members and 1 Guest are viewing this topic.

Offline myste

  • BeBot Rookie
  • *
  • Posts: 12
  • Karma: +0/-0
  • shallabais
IGN Relay
« 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?


Offline Tsuyoi

  • BeBot User
  • **
  • Posts: 30
  • Karma: +0/-0
  • BigT
    • Adrenaline Rush Forums
Re: IGN Relay
« Reply #1 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

Offline myste

  • BeBot Rookie
  • *
  • Posts: 12
  • Karma: +0/-0
  • shallabais
Re: IGN Relay
« Reply #2 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 ;)

Offline myste

  • BeBot Rookie
  • *
  • Posts: 12
  • Karma: +0/-0
  • shallabais
Re: IGN Relay
« Reply #3 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.
« Last Edit: March 12, 2006, 12:27:59 am by myste »

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: IGN Relay
« Reply #4 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 ;)

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: IGN Relay
« Reply #5 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?

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: IGN Relay
« Reply #6 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.

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: IGN Relay
« Reply #7 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.

Offline Dabaron

  • BeBot Apprentice
  • ***
  • Posts: 163
  • Karma: +0/-0
Re: IGN Relay
« Reply #8 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?

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: IGN Relay
« Reply #9 on: August 24, 2006, 11:56:04 am »
Check out the chat relay between org chat and guest channel, especially the start_relay() function.

Offline nebhyper

  • BeBot User
  • **
  • Posts: 62
  • Karma: +0/-0
Re: IGN Relay
« Reply #10 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?

Siocuffin (Squad Commander of United Notum Federation)
alts: Nebhyper, Nebalmighty.

Offline Naturalistic

  • Contributor
  • *******
  • Posts: 221
  • Karma: +0/-0
Re: IGN Relay
« Reply #11 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
220/25 Eternalist Doctor
-----------------------------
Campalot Coding Co-ordinator and Super Admin
http://www.campalot.info/index.php

Offline nebhyper

  • BeBot User
  • **
  • Posts: 62
  • Karma: +0/-0
Re: IGN Relay
« Reply #12 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?
Siocuffin (Squad Commander of United Notum Federation)
alts: Nebhyper, Nebalmighty.

Offline neongen

  • BeBot User
  • **
  • Posts: 64
  • Karma: +0/-0
Re: IGN Relay
« Reply #13 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?

Offline nebhyper

  • BeBot User
  • **
  • Posts: 62
  • Karma: +0/-0
Re: IGN Relay
« Reply #14 on: December 03, 2006, 11:26:26 pm »
I'm still stuck on why check_rights() is giving me issues
Siocuffin (Squad Commander of United Notum Federation)
alts: Nebhyper, Nebalmighty.

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 479
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal