Kentaro Kuribayashi's blog

Software Engineering, Management, Books, and Daily Journal.

Hato: A Tool to Manage Various Notification Methods

Hato is a tool to manage various notification methods. Once you configure notification methods, you can send messages via the methods just by posting them to Hato.

Usage

Launch Hato with hato command:

$ hato -c config.rb

Then, post your notification message:

$ curl -d 'message=test' -d 'tag=test' -d 'api_key=test' http://localhost:9699/notify

Configuration

Hato provides DSLs for configuration.

e.g. config.rb:

Hato::Config.define do
  api_key 'test'
  host    '0.0.0.0'
  port    9699

  tag 'test' do
    plugin 'Ikachan' do
      scheme  'http'
      host    'irc.example.com'
      port    4979
      channel 'hato'
    end

    plugin 'Mail' do
      smtp address:   'smtp.example.com',
           port:      587,
           domain:    'example',
           user_name: 'hato',
           password:  'password',
           enable_ssl: true

      subject_template = <<EOS
[<%= args[:tag] %>] Notification
EOS
      body_template = <<EOS
You've got a message:

<%= args[:message] %>
EOS

      message from: 'hato@example.com',
              to:   [
                'foo@example.com',
                'bar@example.com',
              ],
              subject_template: subject_template,
              body_template:    body_template
    end
  end
end

Plugin Architecture

Hato bundles several plugins by default:

You can easily extend Hato by creating your own plugins. See the source for detail. It's really easy.

Using Hato with Thrid-party Plugins

At first, create a Gemfile to manage dependencies:

source 'https://rubygems.org'

gem 'hato'
gem 'hato-plugin-awesome_plugin'

Then, execute bundle exec hato -c your_config_file