Thanks to Temar and Alreadythere for helping me get this module to work. This is a simple module that makes use of the Say module that comes with the bebot. You must make both bots members of their target bot for this to work. Change TARGET_BOTNAME in the code below to the bot of your alliance guild and then save the file as alliance.php in your modules folder and restart your bot. Get your alliance guild to do the same thing but of course TARGET_BOTNAME for them is the name of your bot instead. It should also be possible to send the messages to more bots by adding this line below the existing one for each extra bot you want to send the message to. Although I can foresee if you add too many bots then you may lose some of the messages due to the flood filter in game, so you may have to add a delay between each tell.
$this -> bot -> send_tell("TARGET_BOTNAME", "say " . $name .": ".$message, 0, FALSE);
Note that I don't have a great understanding of php so I mostly went on using code from the say module and adapting it for what I needed this one to do. So I am sure its far from perfect but it works so I'm happy!
To send a message to your allied guild you type "!alliance <message>" in guild chat and the bot sends it to the target guilds bot which relays it to their guild chat.
<?php
$Alliance = new alliance($bot);
class alliance Extends BaseActiveModule
{
var $bot;
var $msg;
function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));
$this -> register_command("all", "alliance", "MEMBER");
$this -> help['description'] = 'Alliance Message Module';
$this -> help['command']['alliance <message>'] = "- Send a message to allied guild.";
}
function command_handler($name, $msg, $source)
{
$filters = "rot13|chef|eleet|fudd|pirate|nofont";
if (preg_match("/^alliance (".$filters.") (.+)$/i", $msg, $info))
return $this -> send_message($name, $info[2], $info[1]);
else if (preg_match("/^alliance (.+)$/i", $msg, $info))
return $this -> send_message($name, $info[1]);
else return "Learn how to use the command. See !help alliance";
}
function send_message($name, $message, $filter="off")
{
$filter = strtolower($filter);
if ($filter <> "off")
{
$message = $this -> bot -> core("stringfilter") -> funmode($message, $filter);
}
$this -> bot -> send_tell("TARGET_BOTNAME", "say " . $name .": ".$message, 0, FALSE);
$this -> bot -> send_gc("Your message has been sent to allies.");
}
}
?>