ircbot

An irc bot framework that offers easy-to-use by plugins

Config

Edit "config/xxx.yml" as your environment.

* host: irc server host
* port: irc server port
* nick: nick name for this bot
* user: user name for this bot
* real: real name for this bot
* help: help message for this bot
* channels: startup channel names
* plugins: plugin names
* timeout: bot will exit when no new pings come for this sec

Usage

ircbot -f config/xxx.yml

Plugin

In ircbot world, we define functions as plugin (Ircbot::Plugin).

Instance methods:
  * reply : this method is called when privmsg event is fired,
            and reply message(the returned string) to the channel.
      args: [text, nick, message object]

  * help  : used from "plugins" plugin

Accessor methods:

  * message : message object same as 3rd argument
  * direct? : whether the message is directly toward to the bot or not
  * config  : hash of given config file

Example

When you want echo bot, define the function as plugin first.

plugins/echo.rb:

  class EchoPlugin < Ircbot::Plugin
    def reply(text)
      text
    end
  end

Advanced

Messages are passed into plugins automatically.
If you don't want this plugin chain, throw :done will help you.  

  config:
    plugins: a b

  class APlugin < Ircbot::Plugin
    def reply(text)
      throw :done, "This is A"
    end
  end

  class BPlugin < Ircbot::Plugin
    def reply(text)
      "This is B"
    end
  end

BPlugin#reply will be never invoked.

Required

* irc-net gem

Authors: [email protected] Links: github.com/maiha/ircbot