BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => AO 0.6 support => Topic started by: -Fionn- on February 08, 2009, 07:36:35 pm
-
I would like to setup a simple guild alliance chat module between two bebots. How I want it to work is that it will use the builtin 'Say' module on the bot. So basically people in guildchat type "!alliance We need help in Keshatta, lots of xyz guild are around killing everyone" and the alliance module then takes that message and sends it in a tell to the other bot with Say before the message so it displays in their guild chat. Both bots would be members of the other bot to allow this to work. I know it should be quite simple to setup but I don't know exactly how to create the module.
Can someone please show me how I get the bot to send a tell in php? Do I use chatcmd:// or how do I do it. Any help you can give would be appreciated. In case of other suggestions to make this work, we don't want all normal guild chat to be linked but we want to be able to speak in each others guild chat when needed.
Thanks,
Fionn
-
So basically all I need to know is how I write in php to get the bot to send a tell to someone in game?
-
$this->bot->send_tell($targetbot, "!say " . $whatever) is your friend ;)
-
you should actually put <pre> instead of ! that way it will put your prefix even if your change it
or if the target being a dif bot and they might not have same prefix you might wana add a setting were you can define it
or dont use prefix at all but this will req the bot to allow no prefix (most do)
-
Excellent, thanks very much for your help. I should be able to sort this out now. :D
-
This is my code
<?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("alliance");
$this -> help['description'] = 'Alliance Message Module';
$this -> help['command']['alliance <message>'] = "- Send a message to allied guild.";
}
function command_handler($name, $msg, $origin)
{
if (preg_match("/^alliance$/i", $msg))
return $this -> send_message($msg);
else return "Learn how to use the command. See !help alliance";
}
function send_message($msg)
{
$this->bot->send_tell(bettie, "say " . $msg)
}
}
?>
When I attempt to start the bot it tells me that there is an unexpected } at line 34. I have checked a few times and I don't see that I have an extra } in there so I presume it's something else I have incorrect?
-
because you missed the ; at end of the $this->bot->send_tell(bettie, "say " . $msg)
-
also you should put bettie in " "
you also need to use no color by telling the function to not color it see below
$this -> bot -> send_tell("bettie", "say " . $msg, 0, FALSE);
-
Thanks again for your help, I'll add the changes and hopefully it will work.
-
I got the module working. This is the code I used in the end. Thanks for your help on this one. 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 quite well so I'm happy!
<?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("bettie", "say " . $name .": ".$message, 0, FALSE);
$this -> bot -> send_gc("Your message has been sent to allies.");
}
}
?>