BeBot - An Anarchy Online and Age Of Conan chat automaton
Development => Module Requests => Topic started by: Malosar on March 30, 2006, 05:04:09 am
-
I'd write this myself if I really knew what I was doing, however I can't so im asking if someone can write one up quickly as it shouldn't take long. All I need is a simple module to relay a tell from a specific username to guild chat. So if the bot gets a tell from Infonet it will relay the same message to guild chat.
Im in the process of finally converting my guild bot to bebot and I wrote in my own code in IGN bot to handle this, however not sure how to go about it in bebot.
-
Looking for a way to do this as well. Would be a nice feature to have.
-
That's easy :P
$commands["tell"][] = &$mod;
function tell ($name, $msg)
{
if (preg_match(yadda yadda))
{
$this->bot->send_gc ($msg);
}
}
That of course is just to give you the idea of what to do. If you want to relay *anything* from infonet, just change the preg_match to:
if ($name == "Infonet")) {} instead. To get it working, you'll have to fix it up :P Hope that helps.
-
The following is quick but ugly (there're nicer ways to do this).
At the top you can set a list of nick of people from whom you'd like to accept tells to be relayed.
(Tells must be in the format of: !relaytell <message to relay>)
<?
/*
* RelayTell.php - Relays tells from certain members to GC
*
* BeBot - An Anarchy Online Chat Automaton
* Copyright (C) 2004 Jonas Jax
*
* Developed by Blondengy (RK1)
* Special thanks goes out to Khalem (RK1) for his support.
*
* File last changed at $LastChangedDate$
* Revision: $Id$
*/
// List of people from whom to relay:
$relaytellnames["SomeGuy1"] = 1;
$relaytellnames["SomeGuy2"] = 1;
$relaytellnames["Malosar"] = 1;
$relaytellnames["ifonet"] = 1;
$relaytell = new RelayTell($bot, $relaytellnames);
$commands["tell"]["relaytell"] = &$relaytell;
$commands["tell2"]["relaytell"] = &$relaytell;
/*
The Class itself...
*/
class RelayTell
{
var $bot;
var $names;
/*
Constructor:
Hands over a referance to the "Bot" class
*/
function RelayTell (&$bot, &$names)
{
$this -> bot = &$bot;
$this -> names = $names;
}
/*
This gets called on a tell with the command
*/
function tell($name, $msg)
{
if (($this -> names[$name]) && preg_match("/^" . $this -> bot -> commpre . "relaytell (.+)$/i", $msg, $info))
$this -> bot -> send_gc("<font color=#ffff00>$name:</font> " . $info[1]);
}
/*
This gets called on a tell with the command from person outside guild
*/
function tell2($name, $msg)
{
if (($this -> names[$name]) && preg_match("/^" . $this -> bot -> commpre . "relaytell (.+)$/i", $msg, $info))
$this -> bot -> send_gc("<font color=#ffff00>$name:</font> " . $info[1]);
}
}
?>
This should work but since I've cancled my account long ago I have no means of checking... :P
-
You don't have to make it use a tell command, it should work if it matches a specified name.
Needs to be tested, but I'm pretty sure that it would work.
The other way is using a !command like Blond suggested.
-
Thanks for the attempts however the first one won't work because the bot.php overrides incoming tell handling if a command isn't known and will just return a /help to the sender without following any relay rules.
The second one won't work in this regard because the server-wide infonet messages won't include a !relaytell command in them though would be useful for other commands I might want.
So I'd hacked this into the bot.php when it resolves an incoming tell:
/*
Incomeing Tell
*/
function inc_tell($args)
{
$infonet = $this -> aoc -> get_uname($args[0]);
if ($infonet == "Infonet")
{
$this->send_gc("Infonet: ".$args[1]);
}
Which works but the only problem now is to squash any replies to Infonet. Fortunately Infonet is written to not reply to garbage it doesn't understand so it's not a big problem and won't cause tell tennis. I guess I need to hack something into this section to make sure it doesn't reply either response to Infonet. I've added Infonet as a member as well.
if (!$found && $this -> is_member($user))
$this -> send_help($args[0], "/tell " . $this -> botname . " " .
str_replace("\\", "", $this -> commpre) . "help");
else if (!$found)
{
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.");
}
-
if ($infonet == "Infonet")
{
$this->send_gc("Infonet: ".$args[1]);
$found = true;
}
That should stop replies cause it tells the bot that code to handle the tell has been found.
-
if ($infonet == "Infonet")
{
$this->send_gc("Infonet: ".$args[1]);
$found = true;
}
That should stop replies cause it tells the bot that code to handle the tell has been found.
ok thanks, starting to work all this out :)
-
That's what I was first saying :P
But I wasn't going to spoon you all the code, learning it on your own = easier to fix in the future.
-
That's what I was first saying :P
But I wasn't going to spoon you all the code, learning it on your own = easier to fix in the future.
Yep i'd rather learn what im doing, thanks for starting me off both of you :)
-
very nice, was looking for this :P works great