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

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

Author Topic: Bebot and other bots/players privategroups  (Read 9362 times)

0 Members and 1 Guest are viewing this topic.

Offline Tefnacht

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Bebot and other bots/players privategroups
« on: May 21, 2007, 03:41:44 pm »
Sorry for my first post being a new thread :-\

A few days ago me and a ingame friend started to work on a new relay system that uses a third bots privategroup to relay the chat from five guilds. All orgbots join that privategroup and send their chat there while copying what other bots say to their own guildchat.
With five bots sharing chat this works much better and faster than using tells (sending the same tell to all other bots) and it does not introduce as many problems like a IRC solution.

We use our own bots. No Bebot, Buda or IGN. However, some of the other guilds we want to relay with use these, so we started to make plugins for those bots... Bebot gives some serious trouble there, because it doesn't offer the ability to join another privategroup at all. Here is what I had to modify to make it work. Maybe this (or something like this) can make it into a later release of Bebot.
It is imho a important core change.

Main.php
Find the line "default:" "in function callback($type, $args)" and add the following before "default:"
Code: [Select]
<?php
case AOCP_PRIVGRP_INVITE:
$bot -> inc_pginvite($args);
break;
?>

Bot.php
Somewhere in the file add:
Code: [Select]
<?php
function inc_pginvite($args)
{
$group $this -> aoc -> get_uname($args[0]);
if (!empty($this -> commands["pginvite"]))
{
$keys array_keys($this -> commands["pginvite"]);
foreach ($keys as $key)
$this -> commands["pginvite"][$key] -> pginvite($group);
}
}
?>

Now in every plugin you can register $commands["pginvite"][] = &$class to catch incoming privategroup invitations.

Code: [Select]
<?php
$example 
= new Example($bot);
$commands["pginvite"][] = &$example;
class 
Example
{
function Example(&$bot)
{
$this -> bot = &$bot;
}

function pginvite($group)
{
$this -> bot -> aoc -> privategroup_join($group);
}
}
?>

Now there is another problem with "inc_pgjoin", "inc_pgleave" and "inc_pgmsg" in Bot.php. Those functions always assume it is the bots own privategroup that invoked those functions, which is no longer the case.
$args[0] in all three of these functions contains the UID of the privategroup owner that invoked the function. Right now it is completely ignored. Here is how I modified "inc_pgjoin" in Bot.php:

Code: [Select]
<?php
function inc_pgjoin($args)
{
$pgname $this -> aoc -> get_uname($args[0]);
$user $this -> aoc -> get_uname($args[1]);
$this -> log("PGRP""JOIN"$user " joined privategroup ".$pgname.".");
if (!empty($this -> commands["pgjoin"]))
{
$keys array_keys($this -> commands["pgjoin"]);
foreach ($keys as $key)
$this -> commands["pgjoin"][$key] -> pgjoin($user$pgname);
}
}
?>

"inc_pgleave" and "inc_gmsg" need to be altered in the same way.

Code: [Select]
<?php
function inc_pgleave($args)
{
$pgname $this -> aoc -> get_uname($args[0]);
//snip
$this -> commands["pgleave"][$key] -> pgleave($user$pgname);
//snip
}
?>

Code: [Select]
<?php
function inc_pgmsg($args)
{
$pgname $this -> aoc -> get_uname($args[0]);
//snip
$this -> commands["pgmsg"][$comms[$i]] -> pgmsg ($user$args[2], $pgname);
//snip
$this -> commands["privgroupall"][$comms[$i]] -> privgroupall($user$args[2], $pgname);
//snip
}
?>

Now all guestchannel functions that use these three need to make sure that $pgname == $this -> bot -> botname before they react. If $pgname is not the botname, the function was invoked from another privategroup (someone joined or left another privategroup or the message comes from another privategroup).
Since the $group variable is given last, no alterations need to be made to any module UNLESS you really want to use other bots/players privategroups with your bot.
If you're not using other privategroups you can keep ignoring $pgname.

Last, send_pgroup in Bot.php needs to be altered so we can send chat to other privategroups.

Code: [Select]
<?php
function send_pgroup($msg$group NULL)
{
if ($group == NULL)
$group $this -> botname;
$gid $this -> aoc -> get_uid($group);
$send true;
if (preg_match("/<a href=\"(.+)\">/isU"$msg$info))
{
if (strlen($info[1]) > $this -> maxsize)
{
$this -> cut_size($msg"pgroup");
$send false;
}
}
if ($send)
{
$msg str_replace("<botname>"$this -> botname$msg);
$msg str_replace("<pre>"str_replace("\\"""$this -> commpre), $msg);
$msg utf8_encode($msg);
$this -> aoc -> send_privgroup($gid"<font color=" $this -> group_color ">" $msg "</font>");
}
}
?>

That's it. Now the bot is ready to interact with other privategroups than his own.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #1 on: May 23, 2007, 03:29:58 am »
Excellent!

This is actually something I've been pondering in the back of my mind for a long time.

Any chance on getting this added to the SVN? :D

Offline Blueeagle

  • Omnipotent
  • BeBot Hero
  • ******
  • Posts: 323
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #2 on: May 23, 2007, 07:34:58 am »
Well this is a nice concept. My concern would be people mass-inviting the bot to private groups all around so it would need some concideration as for security.

I am thinking setting an access level requirement on this, but that would give the relay bot some access to the guild/raid bot and I'm not sure that it would be appropriate.

A better alternative might be a special configuration directive/setting that gives only approved relay bots access to the command.

Also it would need conciderations as to set up filters for what's relayed and the overhead caused by such a filter needs to be evaluated.

Lastly conciderations need to be put into wether or not this should be a replacement for the existing guild relay. I don't think that's fesable as the relaying bot is not bebot and thus this would most likely remain a custom module as we have got no control over which bot is used as a relay bot and implementing filters would be hard concidering that we cannot dictate how messages are relayed or presented by the relay bot. I might be wrong on this tho.

Also setting up a dedicated relay bot for a two-guild relay might be concidered overkill.

This would need more research before being put into SVN and with the current development rate I am thinking 0.5 is most likely target for this.
The only problem that can't be solved by adding another wrapper is having too many wrappers.

Offline Tefnacht

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #3 on: May 23, 2007, 08:37:04 am »
This is not about a relay. It is about Bebot not being able to interact with other privategroups than his own (and how to "fix" that). One possible use for this missing feature would be a relay but it's not limited to that. Guess I shouldn't have talked about the relay stuff in the first place. ;D

I had a talk with someone else about this outside the forums and he said it would be much better to modify inc_pgjoin, inc_pgleave and inc_pgmsg in a way that does not require any changes to other modules. He suggested creating a new set of object function names used with external privategroups.

Code: [Select]
<?php
function inc_pgjoin($args)
{
$pgname $this -> aoc -> get_uname($args[0]);
$user $this -> aoc -> get_uname($args[1]);
$this -> log("PGRP""JOIN"$user " joined privategroup ".$pgname.".");
if ($pgname == $this -> botname) {
if (!empty($this -> commands["pgjoin"]))
{
$keys array_keys($this -> commands["pgjoin"]);
foreach ($keys as $key)
$this -> commands["pgjoin"][$key] -> pgjoin($user);
}
} else {
if (!empty($this -> commands["extpgjoin"]))
{
$keys array_keys($this -> commands["extpgjoin"]);
foreach ($keys as $key)
$this -> commands["extpgjoin"][$key] -> extpgjoin($pgname$user);
}
}
}
?>

Now someone joining the bots own privategroup triggers the old pgjoin($user) function while someone joining an external group the bot is in triggers extpgjoin($pgname, $user).
Plugins that want to use it would have to register it in the $commands array.

Same would have to be done for extpgleave and extpgmsg.

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #4 on: May 23, 2007, 11:24:39 am »
I like the concept, and yes, bebot is missing this. So I may get around to add it soon to SVN.

Just got to get a handle on the security side as Blueeagle said.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #5 on: May 23, 2007, 06:40:42 pm »
The problem with tells is that they're sooooo limited and slow.

For example, if I'm changing a lot of commands access levels, I can only do 3-4 at a time, else I might have *THOUGHT* I changed a level, and really didn't (due to time lag).

With this change I could invite the bot to my private group, spam it with changes, get results back instantly, and not worry about spamming guest chat.

And yes, I realize that !commands doesn't work in priv group currently, it was just an example.  :)

Perhaps a better example would be adding people to a raidlist.  Can't do it in tells if you're trying to add 60+ people in a reasonable amount of time without killing the bot's ability to reply to other people (who are spamming !mypoints or something silly).

Again, invite to your own private group, spam your 60+ adds, and it takes effect virtually instantly without spamming the raid channel.

And I would use this in a heartbeat for a relay between two orgs, if for nothing else than to remove the delay when lots of chat is going on and speed up the bots responses to tells.
* Ebag333 edits

As for security, why can't it be something as simple as adding a list of approved private groups it can join?  If it gets an invite from an approved person/bot/etc, it joins, else it ignores it.
« Last Edit: May 23, 2007, 06:43:01 pm by Ebag333 »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #6 on: May 23, 2007, 06:47:27 pm »
As for security, why can't it be something as simple as adding a list of approved private groups it can join?  If it gets an invite from an approved person/bot/etc, it joins, else it ignores it.
Nothing wrong with this, that's the idea I favor too.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #7 on: May 23, 2007, 08:26:57 pm »
Hmm, trying to get this to work and I'm doing something stupid.  Like usual.   ;D


Code: [Select]
<?php

$relay 
= new Relay($bot);

$commands["pginvite"][] = &$relay;

class 
Relay
{
var $bot;

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

function pginvite($group)
{
echo "We got invited!  Yay!\n";
$this -> bot -> aoc -> privategroup_join($group);
}
}
?>


I also threw a debug message in Bot.php

Code: [Select]
<?php

/*
* Incoming private group invite
*/
function inc_pginvite($args)
{
echo "DEBUG: We hit the pginvite in bot.php\n";
$group $this -> aoc -> get_uname($args[0]);

if (!empty($this -> commands["pginvite"]))
{
echo "DEBUG: We found a command!\n";
$keys array_keys($this -> commands["pginvite"]);
foreach ($keys as $key)
$this -> commands["pginvite"][$key] -> pginvite($group);
}
}

?>


I hit the inc_pginvite function, but evidentally (!empty($this -> commands["pginvite"])) always comes up empty...

Anyone spot where I went wrong?

Offline Tefnacht

  • BeBot Rookie
  • *
  • Posts: 5
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #8 on: May 23, 2007, 09:03:45 pm »
Looks perfectly fine. If (!empty($this -> commands["pginvite"])) comes up false it means it is really not defined. Add a debug echo to the very beginning of your module php file and to your classes constructor.
Only reason I can see for it not to work is that the bot does not load the module php file and the line "$commands["pginvite"][] = &$relay;" is never processed.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #9 on: May 23, 2007, 09:12:45 pm »
Hmm, odd.

It was named GuildRelay_GUILD.php and wouldn't load.  Renamed it to just Relay.php, loaded no problem.

D'oh!

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #10 on: May 23, 2007, 09:34:54 pm »
You running that bot in raid mode? Wouldn't load then, Main.php loads GUILD modules only in guild mode, as RAID modes are only loaded in raid mode.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #11 on: May 24, 2007, 08:26:04 am »
Humph.  Well, it's always the little things that get you.

Okay, I've made the modifications, and for those who don't want to try and do it yourself, I've uploaded what I've done.

Couple of significant changes from the previous posts.  One of the bigger ones is that any messages posted by the bot to another privgroup (not its own) is sent out unformatted, so you have to handle that yourself if you ever need to do that.  The bots own group is handled normally.

The bot doesn't ask for an invite to the relay channel.  Need to add that on connect.  (Just do an !inviteuser from the relay chan.)

Also, the module rolls the guild relay and priv group relay into one.  Currently the relay bot is hardcoded, so do a find/replace for cafrelay, I aim to change that to be modifiable here hopefully soon.

This only relays org/pgmsg, it doesn't relay logon/offs, etc.  Those will need to be changed in their individual functions.

Also the module has *NO* security what-so-ever.  I will be adding in basic security functions here soon.

To install you need the latest SVN bot (0.3.4).  This will not work on 0.2.X, and probably won't work for 0.3.3 either.

To install:

Main.php goes in the root folder.
Bot.php goes in Sources.
Relay.php goes in Modules.



I will say this, the bots are relaying incredibly faster, even people in my org noticed a huge difference.

The bot response time is much improved as well, since it's no long sending out tons of tells for relay purposes.  I've noticed a huge difference here.

All in all, probably one of the better changes I think I've done.  WTB in SVN.  :)
« Last Edit: May 24, 2007, 08:31:09 am by Ebag333 »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #12 on: May 24, 2007, 07:12:38 pm »
Changes to Main.php and Bot.php commited to SVN (with just slight visual changes).

I don't like the double use of access rights for pgmsg, best would be to add extpgmsg as a dedicated new channel to right management.

Offline Ebag333

  • Contributor
  • *******
  • Posts: 134
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #13 on: May 24, 2007, 09:25:51 pm »
I don't really care for it either, but adding a second way of handling private groups smacks of the same thing as tell and tell2.

A private group is a private group in a lot of ways, but whats really needed is a way of controlling if it responds to commands outside of it's own privategroup.  (For example you may want it to join private groups to monitor whats going on, but not actually respond to commands there.)

Still, I think that can be handled in the modules themselves rather than in the bot core.  Since we have a way of differing between the bots own private group and everyone elses, we can configure the modules appropriately (for example in the module I posted above, !gcr will work in any private group, but not in the bots own group).

* Ebag333 edits

Oh, something I forgot to do on inc_pgleave and inc_pgjoin (though I did hit the other ones).

I think we need to add this bit of code:

Code: [Select]
<?php

if (empty($pgname) || $pgname == "")
$pgname $this -> botname;

?>


at some point after: $pgname = $this -> aoc -> get_uname($args[0])

That should ensure we don't get a null $pgname, which causes the bot to assume it's an exterior group (when in fact it's most likely the bots own group).
« Last Edit: May 24, 2007, 09:37:58 pm by Ebag333 »

Offline Alreadythere

  • BeBot Maintainer
  • BeBot Hero
  • ******
  • Posts: 1288
  • Karma: +0/-0
Re: Bebot and other bots/players privategroups
« Reply #14 on: May 24, 2007, 11:25:50 pm »
I don't really care for it either, but adding a second way of handling private groups smacks of the same thing as tell and tell2.

A private group is a private group in a lot of ways, but whats really needed is a way of controlling if it responds to commands outside of it's own privategroup.  (For example you may want it to join private groups to monitor whats going on, but not actually respond to commands there.)
I think it's something different then tell and tell2, as we are dividing the handlers for those commands based on the channel of origin, not on any membership of the caller.

Though I'm not sure we want to add any central access control for commands in those external chat groups, instead of handling valid channels to join and callers for commands inside any module using external chat groups.

As long as we got no default modules supporting any external chat groups I don't see much point in implementing any centralized security.

 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


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


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

* Who's Online
  • Dot Guests: 279
  • 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