BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Anarchy Online Archive => BeBot 0.5 support => Topic started by: ideus on September 21, 2008, 09:40:25 am
-
I have been trying to find a way to use multiple prefixes. For example -online and !online will do the same, is there a simple solution in "Bot.conf"
at: $command_prefix = "-";
that can be modified to have say $command_prefix = "-" or "!";
Thank you.
-
no the codeing its self would have be changed to support multi prefixes
ill make u a simple module to do a check for dif prefix abit later today
-
If prefix is still handled with regexp (it was before), it's easy. Something along the lines of "(?:-|!)" might work if I remember my regexp correctly.
But if prefix isn't handled by regexp anymore, as it might with the newer versions, this wont work!
-
no i think its more simple like $msg[0] == $prefix
-
here you go, untested
<?php
/*
* Alt_Prefix.php - Module that enables more than 1 Prefix.
*
* Made by Temar
*
* - Coded for Bebot 0.5
*
* You are Free to Improve and Change as Long as My name Stays on it
*
* Add a "_" at the beginning of the file (_ClassName.php) if you do not want it to be loaded.
*
* Version: 1.0
*/
$altprefix = new AltPrefix($bot);
class AltPrefix extends BasePassiveModule
{
function __construct(&$bot)
{
parent::__construct(&$bot, get_class($this));
$this -> register_event("gmsg");
$this -> register_event("tells");
$this -> register_event("privgroup");
$this -> bot -> core("settings") -> create("Core", "AltPrefix", "", "What Other Prefixes are are Allowed seperated by @##@ so . and @ would be .@##@@");
}
function privgroup($name, $msg)
{
Return $this -> check($name, $msg, "pgmsg");
}
function tells($name, $msg)
{
Return $this -> check($name, $msg, "tell");
}
function gmsg($name, $msg)
{
Return $this -> check($name, $msg, "gc");
}
function check($name, $msg, $origin)
{
$prefix = $this -> bot -> core("settings") -> get("Core", "AltPrefix");
$prefix = str_replace(" ", "", $prefix);
$prefix = explode("@##@", $prefix);
foreach($prefix as $pre)
{
if($msg[0] == $pre)
{
$msg[0] = $this -> bot -> commpre;
$this -> bot -> handle_command_input($name, $msg, $origin);
Return TRUE;
}
}
}
}
?>
-
yeah i've been trying to figure out since a couple of my orgs are very used to the prefix '-' and i linked another org with '!'. That is no problem, but I recently started a raidbot for the org and for anyone outside the org, I just notice everyone in the org uses '-' and everyone outside the org constantly use '!'. I really appreciate all your help on this I thought it could have been done by a simple thing added in the bot.conf that I couldn't figure out but when I couldn't figure that out the next thought I had was that I'd have to modify each module somehow in the raidbot to allow one or the other. For me being noobish at php it'd take me a but but I've been working on it just playing around with php learning new stuff as I go.
I just realized you posted the new module, I'm going to give it a try and really appreciate it. Thank you very much!
-
:D works great thanks so much for your time!