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: Making our Relay work for 0.5.3+  (Read 3721 times)

0 Members and 2 Guests are viewing this topic.

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Making our Relay work for 0.5.3+
« on: September 10, 2008, 12:35:06 am »
Hi, we currently got a relay module we use for a large alliance that currently only work properly on 0.4.x but we would like to make it work/available in a version for 0.5.3+ as well but our skills fail us and the 0.4.x support module does not work for it it seem :P
So we hope anyone could help us out a bit :)

Here is the 0.4.x version:
(not letting us attach the file(even as .phps) so we post the code...)
Code: [Select]
<?php
/*
* Alliance Relay Module
*
* By: Heffalomp and Snoopshake @ RK2
*
* Thanks to: Hyde, Temar, all the nice people in the bebot community, and the creators of BeBot :)
*
*/

/*
Add a "_" at the beginning of the file (_ClassName.php) if you do not want it to be loaded.
*/

$hrelay = new HRelay($bot);
// $bot -> relay = &$hrelay;

/*
Bind the command to the bot.
*/
// Incomming relay
$commands["tell"]["agcr"] = &$hrelay;
$commands["extpgmsg"]["agcr"] = &$hrelay;

// Outgoing relay
$commands["pgmsg"]["command"] = &$hrelay;
$commands["gc"]["command"] = &$hrelay;

$commands["gmsg"][$guild_name][] = &$hrelay;
$commands["privgroup"][] = &$hrelay;


// Connecting to hubs
$commands["pginvite"][] = &$hrelay;

/*
The Class itself...
*/
class HRelay
{
var $bot;
var $help;


/*
Constructor:
Hands over a referance to the "Bot" class.
Defines access control for the commands
Creates settings for the module
Defines help for the commands
*/
function HRelay (&$bot)
{
$this -> bot = &$bot;

/*
Preventing abuse of relay cmds
*/
$this -> bot -> accesscontrol -> create('tell''agcr''SUPERADMIN');
        
$this -> bot -> accesscontrol -> create('extpgmsg''agcr''MEMBER');
//$this -> bot -> accesscontrol -> create ('tell', 'command', 'GUEST');
//$this -> bot -> accesscontrol -> create ('gc', 'command', 'ADMIN');
//$this -> bot -> accesscontrol -> create ('pgmsg', 'command', 'MEMBER');

/*
Allowing settings to be changed ingame
*/

/*
Relays, Change This next Line to add more relays 
*/
$this -> relays = array(=> "one"=> "two"=> "three"=> "four"=> "five");


foreach($this -> relays as $relaynum => $relayname)
{
$this -> bot -> settings -> create('HRelay'.$relaynum'farSyntax''!''The syntax pre-ID of the bot on the far side of relay'.$relaynum);
$this -> bot -> settings -> create('HRelay'.$relaynum'nearSyntax''@''The syntax to send a message to relay'.$relaynum);
$this -> bot -> settings -> create('HRelay'.$relaynum'Priv''Both''Where should private group relay to''Both;Guildchat;Relaybots;None');
$this -> bot -> settings -> create('HRelay'.$relaynum'Org''Both''Where should guild chat group relay to''Both;Privgroup;Relaybots;None');
$this -> bot -> settings -> create('HRelay'.$relaynum'Inc''Both''Where should incoming messages relay to''Both;Guildchat;Privgroup;None');
$this -> bot -> settings -> create('HRelay'.$relaynum'Relay''''What is the name of the bot that we are using as a relay?');
$this -> bot -> settings -> create('HRelay'.$relaynum'Status'TRUE'Relay should be');
$this -> bot -> settings -> create('HRelay'.$relaynum'Type''Tells''How should we relay, via a private group or via tells?  Tells is not the recommended method of handling relays, is slower, and less reliable, and can only be used between two bots.  See the help for <pre>gcr for more information.''Pgroup;Tells');
$this -> bot -> settings -> create('HRelay'.$relaynum'Pgname'$this -> bot -> guildname ' Guest''What name should we show when we relay from the private group?');
$this -> bot -> settings -> create('HRelay'.$relaynum'Gcname'$this -> bot -> guildname'What name should we show when we relay from guild chat?');
$this -> bot -> settings -> create('HRelay'.$relaynum'StrictNameCheck'TRUE"Has the name of the sender of tells with <pre>gcr commands to be an exact match with the name of the relay bot?");
$this -> bot -> settings -> create('HRelay'.$relaynum'IRC'TRUE"Relay to IRC?");
}

/*
Coloring
*/
foreach($this -> relays as $relaynum => $relayname)
{
$this -> bot -> colors -> define_scheme("hrelay".$relayname"channel""normal");
$this -> bot -> colors -> define_scheme("hrelay".$relayname"name""normal");
$this -> bot -> colors -> define_scheme("hrelay".$relayname"message""normal");
}

$this -> help['description'] = 'Handles misc/large relay setups';
//$this -> help['command']['command1']="- What does command1 do without any keywords";
//$this -> help['command']['command1 keyword'] = "- What does command1 do with keyword";
//$this -> help['command']['command2 keyword'] = "<param> - What does command2 do with <param>";
$this -> help['notes'] = "Here there might pop some help one day.";
}



/*
This is somewhat a kludge until the internal handling of commands gets altered, in the future, these functions will be depreciated and
the command handler will be called directly.
Just pass off to the unified handler
*/
function pginvite($group)
{
foreach($this -> relays as $relaynum => $relayname)
{
if (strtolower($this -> bot -> settings -> get('HRelay'.$relaynum'Relay')) == strtolower($group))
$this -> bot -> aoc -> privategroup_join($group);
}
}

/*
This gets called on a msg in the private group.
This is where we send our message to org chat and to our relay.
*/
function privgroup($name$msg)
{
$this -> relay_to_pbot1($name$msg);
}

/*
This gets called on a msg in the group.
This is where we send our message to the private group and to our relay.
*/
function gmsg($name$group$msg)
// {
// if (preg_match("/^" . $this -> bot -> settings -> get('HRelay1', 'nearSyntax') . " (.+)/i", $msg))
// {
// $this -> relay_to_bot($name, $msg);
// $this -> relay_to_pgroup($name, $msg);
// }
// else 
{
$this -> relay_to_pgroup2($name$msg);
}
// }
/*
This gets called on a tell with the command
*/
function tell($name$msg)
{
foreach($this -> relays as $relaynum => $relayname)
{
if (preg_match("/^" $this -> bot -> commpre "agcr /im"$msg) &&
$this -> bot -> settings -> get('HRelay'.$relaynum'Status') && (($this -> bot -> settings -> get('HRelay'.$relaynum'StrictNameCheck') &&
strtolower($this -> bot -> settings -> get('HRelay'.$relaynum'Relay')) == strtolower($name)) ||
!($this -> bot ->  settings -> get('HRelay'.$relaynum'StrictNameCheck'))))
{
$parts explode(' '$msg);
unset($parts[0]);
$txt implode(' '$parts);

/* Hyde: parse out the Channel, Name and Message text, colorize it using the hrelayone colors */
if (preg_match("/\[<font color=#[ABCDEFabcdef0-9]{6}>([^\]]*)<\/font>\] <font color=#[ABCDEFabcdef0-9]{6}>([^\ ]*):<\/font> <font color=#[ABCDEFabcdef0-9]{6}>(.*)<\/font>$/"$txt$matches) || preg_match("/\[([^\]]*)] ([^\ ]*): (.*)$/"$txt$matches))
{
$txtirc "[" $matches[1] . "]" $matches[2] . ": " $matches[3];
$txt_channel = ("##hrelay".$relayname."_channel##" $matches[1] . "##end##");
$txt_name = ("##hrelay".$relayname."_name##" $matches[2] . "##end##");
$txt_message = ("##hrelay".$relayname."_message##" $matches[3] . "##end##");
$txt "[" $txt_channel "] " $txt_name ": " $txt_message;
}

if ($this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Guildchat")
{
$this -> bot -> send_gc($txt);
}

if ($this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Privgroup")
{
$this -> bot -> send_pgroup($txt);
}
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Irc') == TRUE)
{
$this -> relay_to_irc2($txtirc);
}
}
}
}
/*
This gets called on commands in the external privgroup
*/
function extpgmsg($pgroup$name$msg)
{
foreach($this -> relays as $relaynum => $relayname)
{

if (preg_match("/^" $this -> bot -> commpre "agcr /im"$msg) &&
$this -> bot -> settings -> get('HRelay'.$relaynum'Status') &&
strtolower($this -> bot -> settings -> get('HRelay'.$relaynum'Relay')) == strtolower($pgroup))

/*
if (preg_match("/^" . $this -> bot -> commpre . "agcr /im", $msg) &&
$this -> bot -> settings -> get('HRelay'.$relaynum, 'Status'))
*/
{
$parts explode(' '$msg);
unset($parts[0]);
$txt implode(' '$parts);
            /* Hyde: parse out the Channel, Name and Message text, colorize it using the hrelayone colors */
if (preg_match("/\[<font color=#[ABCDEFabcdef0-9]{6}>([^\]]*)<\/font>\] <font color=#[ABCDEFabcdef0-9]{6}>([^\ ]*):<\/font> <font color=#[ABCDEFabcdef0-9]{6}>(.*)<\/font>$/"$txt$matches) || preg_match("/\[([^\]]*)] ([^\ ]*): (.*)$/"$txt$matches))
{
$txtirc "[" $matches[1] . "]" $matches[2] . ": " $matches[3];
$txt_channel = ("##hrelay".$relayname."_channel##" $matches[1] . "##end##");
$txt_name = ("##hrelay".$relayname."_name##" $matches[2] . "##end##");
$txt_message = ("##hrelay".$relayname."_message##" $matches[3] . "##end##");
$txt "[" $txt_channel "] " $txt_name ": " $txt_message;
}
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Guildchat")
{
$this -> bot -> send_gc($txt);
}

if ($this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Inc') == "Privgroup")
{
$this -> bot -> send_pgroup($txt);
}

if ($this -> bot -> settings -> get('HRelay'.$relaynum'Irc') == TRUE)
{
$this -> relay_to_irc2($txtirc);
}
}
}
}
function relay_to_pgroup2 ($name$msg)
{
foreach($this -> relays as $relaynum => $relayname)
{
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Status') && preg_match("/^" $this -> bot -> settings -> get('HRelay'.$relaynum'nearSyntax') . " (.+)/i"$msg$info))
{
$relaystring "[" $this -> bot -> settings -> get('HRelay'.$relaynum'Gcname') . "] " $name ": " $info[1];
//$relaystring = "[##hrelay".$relayname."_channel##" . $this -> bot -> settings -> get('HRelay'.$relaynum, 'Gcname') . "##end##] ##hrelay".$relayname."_name##" . $name . ":##end## ##hrelay".$relayname."_message##" . $info[1] . " ##end##";
// if ($this -> bot -> settings -> get('HRelay1', 'Org') == "Both" || $this -> bot -> settings -> get('HRelay1', 'Org') == "Privgroup")
// {
// $this -> bot -> send_pgroup($relaystring);
// }
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Relay') != '' &&
($this -> bot -> settings -> get('HRelay'.$relaynum'Org') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Org') == "Relaybots"))
{
$this -> relay_to_bot($relaynum$relaystring);
}
}
}
}
/*
Relays from privgroup to relay (Relay_GUILD.php handles regular privgroup <-> guild relaying)
*/
function relay_to_pbot1 ($name$msg)
{
foreach($this -> relays as $relaynum => $relayname)
{
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Status'))

if (preg_match("/^" $this -> bot -> settings -> get('HRelay'.$relaynum'nearSyntax') . " (.+)/i"$msg$info))
{
$relaystring "[" $this -> bot -> settings -> get('HRelay'.$relaynum'Pgname') . "] " $name ": " $info[1];
//$relaystring = "[##hrelay".$relayname."_channel##" . $this -> bot -> settings -> get('HRelay'.$relaynum, 'Pgname') . "##end##] ##hrelay".$relayname."_name##" . $name . ":##end## ##hrelay".$relayname."_message##" . $info[1] . " ##end##";
if ($this -> bot -> settings -> get('HRelay'.$relaynum'Relay') != '' &&
($this -> bot -> settings -> get('HRelay'.$relaynum'Priv') == "Both" || $this -> bot -> settings -> get('HRelay'.$relaynum'Org') == "Relaybots"))
{
$this -> relay_to_bot($relaynum$relaystring);
}
}
}
}

// Relays $msg without any further modifications to other bot(s).
// If $chat is true $msg will be relayed as chat with added "<pre>gcr " prefix.
// If $chat is false $msg will be relayed as it is without any addon, this can be used to relay commands to the other bot(s).
function relay_to_bot($bot$msg$chat true)
{
/* if ($chat)
{
$prefix = $this -> bot -> settings -> get('HRelay1', 'farSyntax') . "agcr ";
}
else
{
$prefix = "";
}
*/
if ($this -> bot -> settings -> get('HRelay'.$bot'Status') && $this -> bot -> settings -> get('HRelay'.$bot'Relay') != '')
{
$prefix $this -> bot -> settings -> get('HRelay'.$bot'farSyntax') . "agcr ";
if (strtolower($this -> bot -> settings -> get('HRelay'.$bot'Type')) == "tells")
{
$this -> bot -> send_tell($this -> bot -> settings -> get('HRelay'.$bot'Relay'), $prefix $msg0false);
}
else
{
$this -> bot -> send_pgroup($prefix $msg$this -> bot -> settings -> get('HRelay'.$bot'Relay'));
}
}
}

// Relays $msg to IRC module (and from there after formatting to IRC channel)
function relay_to_irc2($msg)
{
$this -> bot -> send_irc(""""$msg);
}
}
?>
Ugly code as always :P
« Last Edit: September 10, 2008, 06:42:16 pm by johskar »
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline Nytridr

  • BeBot Expert
  • ****
  • Posts: 262
  • Karma: +0/-0
    • Rising Sun
Re: Making our Relay work for 0.5.3+
« Reply #1 on: September 10, 2008, 07:29:40 am »
You may not even have to worry about your modules from just skimming through it.  with the svn and also for a long time in the 5.0+ it has been able to relay almost everything even irc and what not.  If you would like some help PM me and we can figure something out.

Nyt
Co-Prez of Rising Sun RK1 (1st & only org I will ever belong to)

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: Making our Relay work for 0.5.3+
« Reply #2 on: September 10, 2008, 02:50:40 pm »
I think what the original module was doing nyte was allowing any command character to be used on the remote bots, instead of being forced to make multiple bots to handle the command characters...



Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Making our Relay work for 0.5.3+
« Reply #3 on: September 10, 2008, 03:22:33 pm »
are yer dif bots have dif prefixes
im going to add that feature to the official 1

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: Making our Relay work for 0.5.3+
« Reply #4 on: September 10, 2008, 05:09:39 pm »
This is not a open relay that relay all said, it only relay stuff prefixed with the chosen char for that relay (up to 5 relays possible by default, but expandable with just a small change)

Original relay module afaik is an open relay that relay anything said and only working with 1 relay.

It also strips the coloring of what's sent and color it on receiving end instead (so the chat doesn't have to look like an xmass tree just cause botadmin on other end thought it was funny or didn't agree on colors chosen, which kinda help when 10+ orgs relay to each other at once)

And since so many orgs use the same relay it would be nice to be able for them to use newer version of BeBot as well and not being forced to stick with 0.4.x (since they already are being "forced" to run a BeBot bot)
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: Making our Relay work for 0.5.3+
« Reply #5 on: September 10, 2008, 05:26:43 pm »
temar as for the different prefixes, yes....my original relay was a backup bot that used "." as the command char. the main bot used the "!". That caused me to create a bot on the alliance org that used the ".". it worked out, in the fact that I have main bot, using "!" and can do an online, only showing the org, or use the relay bot "." that will give the online status of everyone in relay.

basically it is org 1, main using "!", backup and relay link using "."
org 2 main using "!", backup and relay link using "."
Org 3 main using "." so connect directly to relaybot
org 4 same as 3
and finally relaybot using "." to link everyone together..

now, if we could get the original relay to do multiple prefixes and give a command argument for online to display either everyone, or org specific, it would be great. I could actually lose 3 bots that way...


Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Making our Relay work for 0.5.3+
« Reply #6 on: September 10, 2008, 07:52:44 pm »
the Latest SVN now support dif prefixes

Offline Heffalomp

  • BeBot Apprentice
  • ***
  • Posts: 80
  • Karma: +0/-0
Re: Making our Relay work for 0.5.3+
« Reply #7 on: September 11, 2008, 02:25:40 am »
ok... this is what we've ended up with so far... seems to work, tho not sure if we need the cron 300 in this since we still keep the original relay.php too

http://www.skartland.net/AO/Alliance_Relay_05.rar

Spot any bugs? let us know :)
« Last Edit: September 11, 2008, 02:30:47 am by johskar »
"Ubuntu" is an ancient African word, meaning "I can't configure Slackware"

Offline clashbot

  • BeBot Expert
  • ****
  • Posts: 295
  • Karma: +0/-0
    • Ascension's Home
Re: Making our Relay work for 0.5.3+
« Reply #8 on: September 11, 2008, 01:50:59 pm »
Ok, now that relay works with a variety of prefixes, how can we get online modified for eith sorting by org(guild) orgiving command arguments for either "online org" or "online org2" or just online to list everyone? moving this to a new thread for better visability
« Last Edit: September 11, 2008, 06:44:25 pm by clashbot »

 

* 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: 91
  • 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