BeBot - An Anarchy Online and Age Of Conan chat automaton

Development => Coding and development discussion => Topic started by: Snarfblatt on August 22, 2006, 09:09:25 pm

Title: Quotes output to IRC
Post by: Snarfblatt on August 22, 2006, 09:09:25 pm
I have the quotes module installed. Is there a way to output the quotes to IRC? Or better yet.. is there a way to make "!quotes" work from IRC like "!online" and "!is".
Title: Re: Quotes output to IRC
Post by: Dabaron on August 22, 2006, 10:18:37 pm
As far as it relaying to irc... I recently did that.

Where it says
Code: [Select]
/*
      This gets called on a msg in the guildchat with the command
    */
    function gc($name, $msg)
    {
        $this -> bot -> send_gc($this -> process_command($name, $msg));
    }

Add this right after the send_gc part
Code: [Select]
$this -> bot -> commands["tell"]["irc"] -> irc_send_local($this -> process_command($name, $msg));
If you are using the cron part (having a quote relay every x number of mins) you can add it there too.. but how I have it it shows a different quote in irc than it does in-game since it grabs a random one for each. But here is the change I made... Change this:
Code: [Select]
/*
        This is cron()!
    */
    function cron()
    { // Start function cron()
        if ($this -> nextquote < time() && $this -> settings['AUTO'] == 1)
        { // Start if()
            // Set time of next quote output.
            $this -> nextquote = $this -> nextquote + ($this -> settings['INTERVAL']*60);
            switch ($this -> settings['CHANNEL'])
            { // Start switch
                case "GC":
                    $this -> bot -> send_gc($this -> send_quote(-1));
                break;
                case "PGROUP":
                    $this -> bot -> send_pgroup($this -> send_quote(-1));
                break;
                case "BOTH":
                    $this -> bot -> send_gc($this -> send_quote(-1));
                    $this -> bot -> send_pgroup($this -> send_quote(-1));
                break;
            } // End Switch
        } // End if()

    } // End function cron()

To this:
Code: [Select]
/*
        This is cron()!
    */
    function cron()
    { // Start function cron()
        if ($this -> nextquote < time() && $this -> settings['AUTO'] == 1)
        { // Start if()
            // Set time of next quote output.
            $this -> nextquote = $this -> nextquote + ($this -> settings['INTERVAL']*60);
            switch ($this -> settings['CHANNEL'])
            { // Start switch
                case "GC":
                    $this -> bot -> send_gc($this -> send_quote(-1));
    $this -> bot -> commands["tell"]["irc"] -> irc_send_local($this -> send_quote(-1));
                break;
                case "PGROUP":
                    $this -> bot -> send_pgroup($this -> send_quote(-1));
                break;
                case "BOTH":
                    $this -> bot -> send_gc($this -> send_quote(-1));
                    $this -> bot -> send_pgroup($this -> send_quote(-1));
                break;
            } // End Switch
        } // End if()

    } // End function cron()
Title: Re: Quotes output to IRC
Post by: Snarfblatt on August 22, 2006, 11:26:20 pm
works great thanks.. to sync things up though I did this:

Code: [Select]
function gc($name, $msg)
{
    $quote = $this -> process_command($name, $msg);
    $this -> bot -> send_gc($quote);
    $this -> bot -> commands["tell"]["irc"] -> irc_send_local($quote);
}

Code: [Select]
function cron()
{
   ...
   $quote = $this -> send_quote(-1);
   $this -> bot -> send_gc($quote);
   $this -> bot -> commands["tell"]["irc"] ->   irc_send_local($quote);
   ...
}

Now.. is there anyway to call the !quote command from IRC.. or is that opening up a can of worms?
Title: Re: Quotes output to IRC
Post by: Dabaron on August 23, 2006, 12:43:30 am
good thinking on that, no clue why I didn't think of that minor change.

As far as calling it from IRC, that would take some mods in the IRC.php file.  You can see the irc_is and irc_online functions as a reference for it.
SimplePortal 2.3.7 © 2008-2025, SimplePortal