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

Title: Autogratz Modul for Verison 0.6.5
Post 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
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: snyder on September 23, 2009, 09:39:14 am
there :)

Code: [Select]
<?
$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 &lt;message&gt;']="Adds a congratulations message (use &lt;name&gt; for the characters name and &lt;level&gt; for the characters level).";
        $this -> help['command']['autogratz addlevel &lt;level&gt; &lt;message&gt;']="Adds a congratulations message (use &lt;name&gt; for the characters name and &lt;level&gt; for the characters level).";
        $this -> help['command']['autogratz remove &lt;id&gt;']="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);
                }
            }
        }
    }
}
?>
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: belatu on January 20, 2010, 09:53:11 am
Hello,

what shall i do if want this to get working??

thnaks in advance
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: snyder on January 20, 2010, 12:58:53 pm
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

Code: [Select]
!autogratz add Congratulations <name>, you reached <level> level!
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: shadowrik on January 21, 2010, 04:52:21 am
i love you guys
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Space on March 17, 2010, 10:58:12 am
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:
Code: [Select]
!autogratz add Congratulations <name>, you reached <level> level!
Which is shown in the list!!

Plz help
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: ripperjpx on March 17, 2010, 04:06:18 pm
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?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Anastasia on March 18, 2010, 04:03:29 am
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
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: fowlskins on March 18, 2010, 03:43:25 pm
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
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Drizzurdeen on March 18, 2010, 09:06:22 pm
is the module set ON ???

u could set it ON in the settings !settings
maybee this would help
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: fowlskins on March 18, 2010, 11:14:31 pm
lmao yeah turning it on definatly helps

allthough having it set to default on might be a more intuitive system  ;)

Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Space on March 19, 2010, 04:41:45 pm
You are DA MAN!!!

LOL  :P

All is working...
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: ST34LTH on April 04, 2010, 09:36:52 pm
Thanks m8, its awesome
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: deathwarnt on May 02, 2010, 01:00:52 pm
cool yeah that was my issue, too :D
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: deathwarnt on May 03, 2010, 02:19:11 am
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
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Getrix on May 03, 2010, 06:58:32 am
Quote
$this -> help['command']['autogratz remove &lt;id&gt;']="Removes a levelling message.";
$this -> help['command']['autogratz list']="Displays a list of levelling messages.";

Quote
!help autogratz

The code should be in there as i can see.
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: deathwarnt on May 03, 2010, 09:35:54 am
ok thanks dude.  Was in a rush haha so posted and bailed.  thanks again :D
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: sandman on May 04, 2010, 05:05:39 pm
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.
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Yite on May 05, 2010, 10:00:49 am
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.
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: snyder on May 05, 2010, 11:45:45 pm
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 :)
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Drizzurdeen on May 06, 2010, 11:51:40 am
u can change the channel where the bot ist gratzin ;) ... maybee only tell ... and nocht in gc ... maybee this would help

greetz da drizz
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: deathwarnt on May 07, 2010, 12:56:22 pm
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.
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: sandman on May 07, 2010, 05:16:18 pm
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?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Drizzurdeen on May 07, 2010, 11:38:43 pm
Quote
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

Title: Re: Autogratz Modul for Verison 0.6.5
Post by: deathwarnt on May 08, 2010, 12:37:14 am
awesome thanks dude! 
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: dioniz84 on August 03, 2010, 09:42:05 am
Hi there.
Is this module working with curent bebot/IRC wersion??
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Yite on August 03, 2010, 10:52:50 am
yes
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: dragonjr on September 03, 2010, 03:15:41 am
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?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Yite on September 03, 2010, 09:42:16 am
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?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: dragonjr on September 03, 2010, 03:34:31 pm
thank you for the help
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: Skidrow on May 03, 2011, 09:32:01 pm
Get error msg on line 1 when i try to add this mod, dont know if it dont work on newer bebot.
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: bertone on June 15, 2011, 07:22:57 pm
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?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: uberjon on June 16, 2011, 12:32:10 am
have you tried the !restart or !shutdown commands? what about force close the process?
Title: Re: Autogratz Modul for Verison 0.6.5
Post by: bertone on June 18, 2011, 07:11:13 pm
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.
SimplePortal 2.3.7 © 2008-2024, SimplePortal