Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

my eventmachine irc bot

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 mirai
Octocat-spinner-32 plugins
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.markdown
Octocat-spinner-32 config.yml
Octocat-spinner-32 mirai.rb
Octocat-spinner-32 runbot.rb
Octocat-spinner-32 update.rb
README.markdown

Mirai

About

Mirai is yet another ruby irc bot, focused on plugins supplying features over core features in the bot for example the only commands the bot provides without plugins are about-plugin and help [plugin].

Mirai is written using the wonderful EventMachine library, and uses yaml for configuration and sqlite for storage and daemons for background processing the builtin webserver is based on thin. plugins may contain additional dependencies.

Why?

Because I can!, and have different ideas on what a good bot should look like.

How?

After editing the config file (below) run ./runbot start or to not background the process ./runbot start --ontop

Configuration

Dependencies

To install the rubygem dependencies simply run bundle install in the root of the repo.
Mirai should run on ruby 1.9.3.

config.yml

Mirai uses yaml for all configurations, to setup the bot you will need to open config.yml in your favourite editor. When writing plugins you will need to supply a plugin-name.yml file, check writing plugins below for more information.

TODO: expand on config

Writing Plugins

Plugins are subclasses of the Miraii::Plugin class and provide a few helper functions to get you started.
Firstly, lets create a hello world plugin.

Hello World

The folder structure should look similar to the following:
mirai
-> plugins
--> helloworld-plugin
---> helloworld-plugin.yml
---> helloworld.rb

helloworld-plugin.yml should consist of:

Name: Helloworld
Author: Your name <you@email.com>
Version: 0.0.1
Type: Channel
Files: [ helloworld.rb ]

helloworld.rb should consist of:

class HelloworldPlugin < Mirai::Plugin
    def on_register                                                         # Called when the plugin is initialized
        add_channel_handler(/talktome (.*)$/, :test_handler)            # ^talktome
        add_web_handler(/helloworld/, :test_web_handler)                # http://0.0.0.0:3000/helloworld
    end

    def test_handler(info, what)
        privmsg info[:chan], "Well, Hello World! #{info[:nick]}. I don't know what #{what} is!"
    end

    def test_web_handler(env)
        privmsg "#achannel", "Hello world from the web!"
        "OK"                                                                # return text "OK" to the webrequest
    end
end

TODO: expand on plugins more

Builtin Webserver

Mirai contains a built in webserver in order to write plugins for callbacks from webservices (github for instance)

TODO: expand expand

Updates

TODO: self update plugin TODO: plugin auto updates

Todo

TODO: todo

Something went wrong with that request. Please try again.