BeBot - An Anarchy Online and Age Of Conan chat automaton
Archive => Age of Conan Archive => AoC 0.6.x Custom/Unofficial modules => Topic started by: Luclia on September 23, 2009, 01:33:40 am
-
Hi,
just a question
is there a working autogratzmodul for the current Bot-Version ?
Greeting
Luclia
-
there :)
<?
$announceGratz = new autogratz(&$bot);
/*
The Class itself...
*/
class autogratz Extends BaseActiveModule
{
var $bot;
/*
Constructor:
Hands over a referance to the "Bot" class.
*/
function __construct (&$bot)
{
parent::__construct(&$bot, get_class($this));
$this -> register_event('buddy');
$this -> register_command('all', 'autogratz', 'ADMIN', array('add' => 'ADMIN', 'addlevel' => 'ADMIN', 'remove' => 'ADMIN', 'list' => 'ADMIN'));
$this -> bot -> core("settings") -> create("autogratz", "Enabled", "Off", "Turns the functionality of this module on and off.", "On;Off");
$this -> bot -> core("settings") -> create("autogratz", "SendTo", "gc", "Send the message via tell or guild chat.", "gc;tell");
$this -> bot -> db -> query("CREATE TABLE IF NOT EXISTS " . $this -> bot -> db -> define_tablename("gratz_messages", "true") . " (id int(10) unsigned NOT NULL AUTO_INCREMENT, level int(10) unsigned NOT NULL DEFAULT '0', message varchar(255) NOT NULL DEFAULT '', PRIMARY KEY (id)) DEFAULT CHARSET=utf8;");
$this -> bot -> db -> update_table('gratz_messages', 'id', 'add', "ALTER TABLE #___gratz_messages ADD COLUMN id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, DROP PRIMARY KEY, ADD PRIMARY KEY (id);");
$this -> help['description'] = "Congratulates a guild member on gaining a level.";
$this -> help['command']['autogratz add <message>']="Adds a congratulations message (use <name> for the characters name and <level> for the characters level).";
$this -> help['command']['autogratz addlevel <level> <message>']="Adds a congratulations message (use <name> for the characters name and <level> for the characters level).";
$this -> help['command']['autogratz remove <id>']="Removes a levelling message.";
$this -> help['command']['autogratz list']="Displays a list of levelling messages.";
}
function command_handler($name, $msg, $origin)
{
$this->error->reset(); //Reset the error message so we don't trigger the handler by old error messages.
$com = $this->parse_com($msg, array('com', 'sub', 'level', 'message'));
switch($com['sub'])
{
case 'add':
return $this -> add_gratz(0, $com['level'].' '.$com['message']);
case 'addlevel':
return $this -> add_gratz($com['level'], $com['message']);
case 'remove':
return $this -> remove_gratz($com['level']);
case 'list':
return $this -> list_gratz();
}
return 'Please use autograts add or autogratz addlevel to add messages.';
}
function add_gratz($level, $message)
{
$level = trim($level);
if('' == $level)
$level = 0;
if($this -> bot -> db -> query("INSERT INTO #___gratz_messages (level, message) VALUES (".$level.", '".mysql_real_escape_string(html_entity_decode($message))."');"))
return 'The message has been added.';
else
return 'Problem occured while adding a message.';
}
function remove_gratz($id)
{
if($this -> bot -> db -> query("DELETE FROM #___gratz_messages WHERE id = '".mysql_real_escape_string($id)."';"))
return 'The message has been removed.';
else
return 'A problem occured while removing the message.';
}
function list_gratz()
{
$results = $this -> bot -> db -> select("SELECT id, level, message FROM #___gratz_messages ORDER BY level, message");
if (!empty($results))
{
$old_level = -1;
$inside = "Gratz Messages\n\n";
foreach ($results as $val)
{
if($old_level != $val[1])
{
if(0 == $val[1])
$inside .= "<font color='#FFFFFF'>For All Levels :: </font>\n\n";
else
$inside .= "<font color='#FFFFFF'>For Level ".$val[1]." :: </font>\n\n";
}
$inside .= htmlentities($val[2])." [".$this -> bot -> core("tools") -> chatcmd("autogratz remove " . $val[0], "Delete")."]";
$inside .= "\n\n";
$old_level = $val[1];
}
}
return "Gratz Messages :: " . $this -> bot -> core("tools") -> make_blob("click to view", $inside);
}
function buddy($name, $status, $level)
{
if(7 == $status)
{
// If the module is active
if('on' == strtolower($this -> bot -> core("settings") -> get("Autogratz", "Enabled")))
{
if(!is_numeric($level) && !is_int((real) $level))
{
$this -> bot -> log("BUDDY", "LOG", "Invalid level data");
return;
}
$user = $this -> bot -> core("chat") -> get_uname($name);
$mem = $this -> bot -> core("notify") -> check($user);
// Check if $name is a guild member
if ($mem)
{
$class_name = $this -> bot -> core("Whois") -> class_name[$classId];
$who = $this -> bot -> core("Whois") -> lookup($name);
$messages = $this -> bot -> db -> select("SELECT message FROM #___gratz_messages WHERE level = ".$level." ORDER BY RAND() LIMIT 1;");
if (empty($messages))
{
$messages = $this -> bot -> db -> select("SELECT message FROM #___gratz_messages WHERE level = 0 ORDER BY RAND() LIMIT 1;");
if (empty($messages))
{
$message = "Congratulations on level <level>, <name>";
}
}
if('' == $message)
{
$message = array_shift($messages);
$message = $message[0];
}
$message = str_replace('<name>', $name, $message);
$message = str_replace('<level>', $level, $message);
$message = htmlentities($message);
// Send Gratz message to guild chat and log the event
if('gc' == strtolower($this -> bot -> core("settings") -> get("Autogratz", "SendTo")))
$this -> bot -> send_gc($message);
else
$this -> bot -> send_tell($name, $message);
$this -> bot -> log("AUTOGRATZ", "LOG", $name . " achieved level " . $level);
}
}
}
}
}
?>
-
Hello,
what shall i do if want this to get working??
thnaks in advance
-
put it in your bebot dit/custom/modules/Autogratz.php
remember, utf-8 encodeing and no spaces or chars before or after php code
then you restart your bot and type to it
!autogratz add Congratulations <name>, you reached <level> level!
-
i love you guys
-
Hi all,
My 1st post, so please be gentle with me!!! (LOL)
I have done all of the above, and the module is loading as i can set messages and all but.... nobody gets GRATZ when lvl changes???
What am i doing wrong!
the only entry i have done is:
!autogratz add Congratulations <name>, you reached <level> level!
Which is shown in the list!!
Plz help
-
Hi guys,
I have the same problem that Space, Autogratz is running (i think) but not gets Gratz when lvl change.
[16:04] [Guild] [xxx]: !autogratz add Congratulations <name>, you reached <level> level!
[16:04] [Guild] [xxx]: The message has been added.
Gratz Messages
For All Levels ::
Congratulations <name>, you reached <level> level!
Any1 can help me?
-
I thought i would try this one too...
Im having same probs though as others before me...
no one is getting Congratulated :(
Any help would be awesome!!!!
Ana
-
i have this installed but it seemed to me last night that the actual guild annoucment is not appearing when people level so maby that has something to do with it
-
is the module set ON ???
u could set it ON in the settings !settings
maybee this would help
-
lmao yeah turning it on definatly helps
allthough having it set to default on might be a more intuitive system ;)
-
You are DA MAN!!!
LOL :P
All is working...
-
Thanks m8, its awesome
-
cool yeah that was my issue, too :D
-
hello! first off great mod. it's fun :d however I do have a request. There any way you can make it (if there isn't already) how to remove a autogratz message? I put in some funny ones, but some don't find them so funny :O. I tried a few things and without going into the database manualy, is there a means of removeing it? manual db removal is not an option atm. so can you put in a command or somethign to remove a message? thanks
-
$this -> help['command']['autogratz remove <id>']="Removes a levelling message.";
$this -> help['command']['autogratz list']="Displays a list of levelling messages.";
!help autogratz
The code should be in there as i can see.
-
ok thanks dude. Was in a rush haha so posted and bailed. thanks again :D
-
now that offline progression is available could someone add to the module so that instead of the bot announcing every lvl, it types out lvl 1-10 on 1 line. because atm it will announce out every lvl, and if someone adds 20 or more lvls to a char, guildchat will get flooded with messages.
-
now that offline progression is available could someone add to the module so that instead of the bot announcing every lvl, it types out lvl 1-10 on 1 line. because atm it will announce out every lvl, and if someone adds 20 or more lvls to a char, guildchat will get flooded with messages.
I have not noticed this behaviour, it only puts out one message for the new level.
-
when char gaines levels through offline levels it is announced as:
char gain level, now is 55
char gain level, now is 56
char gain level, now is 57
so bot sees that like normal leveling, it doesnt know that its offline :)
-
u can change the channel where the bot ist gratzin ;) ... maybee only tell ... and nocht in gc ... maybee this would help
greetz da drizz
-
Ok so I do the !autogratz remove <message> and it says "message has been removed" but that same message continouslly appears. Does anyone know how to actually remove it? !autogratz remove <message> does not work. At least it doesn't acutally remove the message.
-
and its not possible for the bot to be programmed to wait so that if there are more then 1 "char gain level, now is XX" it will display congrats, blah blah on lvl X-Y and if there are 1 "char gain level, now is XX" it will use the current model?
-
Ok so I do the !autogratz remove <message> and it says "message has been removed" but that same message continouslly appears. Does anyone know how to actually remove it? !autogratz remove <message> does not work. At least it doesn't acutally remove the message.
u have to remove the message ID ... for example !autogratz remove 2
u can see the id with the message list ... just type !help autogratz .. there u can see all the commands for this module
-
awesome thanks dude!
-
Hi there.
Is this module working with curent bebot/IRC wersion??
-
yes
-
ok I'm new at this but if i want to add a certain grats message at a certain lvl like at lvl 20 and lvl 80 how do i add them to work at those pacific lvls?
-
This is what you get when you do a !help autogratz:
autogratz add <message>: Adds a congratulations message (use <name> for the characters name and <level> for the characters level).
autogratz addlevel <level> <message>: Adds a congratulations message (use <name> for the characters name and <level> for the characters level).
autogratz remove <id>: Removes a levelling message.
autogratz list: Displays a list of levelling messages.
So to add a message for people reaching 20 you could write (for example):
!autogratz addlevel 20 Congratulations <name> on reaching level <level>, isn't it about time you left Tortage now?
-
thank you for the help
-
Get error msg on line 1 when i try to add this mod, dont know if it dont work on newer bebot.
-
I'm having some problems getting this module to work.
I made a file named autogratz.php in the custom/modules folder and pasted the script posted. Do I need to change anything in it?
After the script is added, the bot won't restart, even after several tries. What am I doing wrong?
-
have you tried the !restart or !shutdown commands? what about force close the process?
-
No i mean after I try to restart the bot it just goes offline and wont load.
Could it be cause the script gets pasted on one line? Im not sure if there's a log or how to access it.