BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Anarchy Online Archive => 0.2.x Custom/Unofficial Modules => Topic started by: Akarah on November 29, 2005, 08:44:51 am

Title: modified IRC
Post by: Akarah on November 29, 2005, 08:44:51 am
i'm going to be adding a few more commands over the next week or so to the IRC module, here's the first, to add !alts to irc...

first, after the irc_online function, add a new function:
Code: [Select]

    function irc_alts(&$irc, &$data)
    {
      if(!preg_match("/^" . $this -> bot -> commpre . "alts (([a-zA-Z0-9]+).+)$/i", $data -> message, $info))
      {
        $msg = "Please enter a valid name.";
      }
      else
      {
        $info[1] = ucfirst(strtolower($info[1]));
        $msg = "";

        if (!$this -> bot -> aoc -> get_uid($info[1]))
        {
          $msg = "Player " . $info[1] . " does not exist.";
        }
        else
        {
          $main = $this -> bot -> alts -> main($info[1]);
          $alts = $this -> bot -> alts -> get_alts($main);
          $msg = $main . "'s Alts: ";
          if (!empty($alts))
          {
            foreach ($alts as $alt)
            {
              $msg .= $alt . ", ";
            }
          }
          else
          {
            $msg .= "None!";
          }
        }
      }
      $this -> irc -> message(SMARTIRC_TYPE_CHANNEL, $this -> chan, $msg);
    }


then, in the irc_connect function, find the line:
Code: [Select]

      $this -> irc -> registerActionhandler(SMARTIRC_TYPE_CHANNEL, $this -> bot -> commpre.'is (.*)', $this -> bot -> commands["tell"]["irc"], 'irc_is');


add:
Code: [Select]

      $this -> irc -> registerActionhandler(SMARTIRC_TYPE_CHANNEL, $this -> bot -> commpre.'alts (.*)', $this -> bot -> commands["tell"]["irc"], 'irc_alts');


and in the irc_receive function, change the line:
Code: [Select]

      if ((strtolower($data -> message) != strtolower(str_replace("\\", "", $this -> bot -> commpre.'online'))) &&
          (strtolower($data -> message) != strtolower(str_replace("\\", "", $this -> bot -> commpre.'is'))))


to:
Code: [Select]

      if ((strtolower($data -> message) != strtolower(str_replace("\\", "", $this -> bot -> commpre.'online'))) &&
          (strtolower($data -> message) != strtolower(str_replace("\\", "", $this -> bot -> commpre.'is'))) &&
          (strtolower($data -> message) != strtolower(str_replace("\\", "", $this -> bot -> commpre.'alts'))))


and now !alts <name> will work on irc and behave as expected.


now i have a few issues with the way this is done, primarily because if you say !alts or !online or !is anywhere in your sentence on irc, it will interpret it as a command, because it's not strictly matching '!command' at the beginning of the msg, but anywhere in the line. also this will get extremely messy and inefficient if i end up hacking 30 different commands into the module to be used from IRC... so i may have to find another way of doing this.. like making a cmdlist array then walking thru it each time or something hmmm.. ideas? :P

/Aka
Title: modified IRC
Post by: skeezix on December 03, 2005, 10:46:51 pm
would you be able to perform a check on the incoming message itself using this?
http://us2.php.net/manual/en/function.substr.php

both substr() and using $string{0} looks like it would be able to snag just the first character to see if it's either "!" for a command, or another character used only for relaying IRC chat (instead of every line that is spewed)

I'll be at least messing with a little bit of this, as it's amusing when I tell someone in IRC "hey if you wanna see who's online just type !online" and then of course the bot does this :D
Title: modified IRC
Post by: Akarah on December 03, 2005, 10:54:23 pm
yup skeez its on my list of stuff todo ;)
Title: modified IRC
Post by: Akarah on December 03, 2005, 10:56:02 pm
oh i've also added !whois to irc, but i think before i add anything else i need to change how it parses commands ;p
Title: modified IRC
Post by: skeezix on December 04, 2005, 04:33:11 am
yeah I'm pretty new to php and trying to learn my way through.  I 'learned' some php with IGN, but obviously bebot is setup extremely different, using dynamic command lists in an awesome (but hard to understand for me) way.

once I look over the IRC module and see how in the world it's running I'll see what I can change. If I see you posted something before hand then it will save me some time ;)
Title: Re: modified IRC
Post by: joey12344 on June 30, 2006, 08:34:01 am
Very nice! Bump for new features!
Title: Re: modified IRC
Post by: Mephistobane on July 01, 2006, 02:30:53 pm
what about joining channels with passwords?

if there's no functionality for this,could someone please add it in? :P
Title: Re: modified IRC
Post by: jjones666 on July 01, 2006, 06:24:38 pm
Is the channel key option not sufficient?

-jj-
Title: Re: modified IRC
Post by: Mephistobane on July 02, 2006, 04:02:57 am
well, i used it, didnt work. but i tried a channel without password, that didn't work either, so that's odd
SimplePortal 2.3.7 © 2008-2024, SimplePortal