Kris

IRC bot library - Pluggable, and very simple

Gem Version Dependency Status Code Climate endorse


Requirements

  • Ruby 1.9.3 or lator
  • Zircon

Getting started

Install the kris

RubyGems.org

gem install kris

Bundler

Edit a Gemfile

gem 'kris', :git => 'git://github.com/Tomohiro/kris.git'

Install

$ bundle install --path vendor/bundle

Bot project directory structure

my-bot-project
    |-- Gemfile
    |-- MyBot
    `-- plugin
        |-- reply.rb
        `-- crawler.rb

Bootstrap Bot

$ vi my-bot-project/MyBot
#!/usr/bin/env ruby

require 'kris'

Kris::Session.new(
  server:   'chat.freenode.net',
  port:     6667,
  channel:  '#my-bot-channel',
  nickname: 'MyBot',
  username: 'MyBot',
  realname: 'MyBot'
).start

Plugin example

Response

class Reply < Kris::Plugin
  def response(message)
    case message.body.downcase
    when /hello/
      reply(message.to, message.from, 'Hello!')
    end
  end
end

Notification

class Crawler < Kris::Plugin
  def notify
    crawl_datas do |new_data|
      notice('#notify-channel', new_data)
    end
  end

  private
    def crawl_datas
      # do something
    end
end

Run

$ bundle exec ruby MyBot

LICENSE

© 2012 - 2013 Tomohiro TAIRA. This project is licensed under the MIT license. See LICENSE for details.