collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18363
  • stats Total Topics: 2500
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: modified IRC  (Read 2969 times)

0 Members and 1 Guest are viewing this topic.

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified IRC
« 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

Offline skeezix

  • BeBot User
  • **
  • Posts: 21
  • Karma: +0/-0
modified IRC
« Reply #1 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

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified IRC
« Reply #2 on: December 03, 2005, 10:54:23 pm »
yup skeez its on my list of stuff todo ;)

Offline Akarah

  • Contributor
  • *******
  • Posts: 72
  • Karma: +0/-0
    • http://synergyfactor.net/
modified IRC
« Reply #3 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

Offline skeezix

  • BeBot User
  • **
  • Posts: 21
  • Karma: +0/-0
modified IRC
« Reply #4 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 ;)

joey12344

  • Guest
Re: modified IRC
« Reply #5 on: June 30, 2006, 08:34:01 am »
Very nice! Bump for new features!

Offline Mephistobane

  • BeBot User
  • **
  • Posts: 21
  • Karma: +0/-0
Re: modified IRC
« Reply #6 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

Offline jjones666

  • Contributor
  • *******
  • Posts: 353
  • Karma: +0/-0
Re: modified IRC
« Reply #7 on: July 01, 2006, 06:24:38 pm »
Is the channel key option not sufficient?

-jj-

Offline Mephistobane

  • BeBot User
  • **
  • Posts: 21
  • Karma: +0/-0
Re: modified IRC
« Reply #8 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

 

* Recent Posts
[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm]


0.8.x updates for AoC by bitnykk
[January 30, 2024, 11:16:08 pm]


0.8.x updates for AO by bitnykk
[January 30, 2024, 11:15:37 pm]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am]


Bebot and Rasberry by bitnykk
[November 29, 2023, 11:04:14 pm]

* Who's Online
  • Dot Guests: 710
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal