botaku

A Slack bot abstraction, built on top of faye-websocket and httpclient.

use

Botaku provides Botaku::Client and Botaku::Bot.

Botaku::Client

require 'botaku'

#c = Botaku::Client.new(token: 'xxxx-111111111111-aaaaaaaaaaaaaaaaaaaaaaaa')
  # or
c = Botaku::Client.new(token: '.slack_api_token')

c.on('hello') do
  p [ :hello ]
  c.say('born to be alive...', '#test')
end
c.on('message') do |data|
  p [ :message, data ]
  c.say('pong', channel: data['channel']) if data['text'].match(/\A\s*ping\b/)
end

Botaku::Bot

require 'botaku'

class ZeroBot < Botaku::Bot

  def on_hello

    p [ :on_hello, _self['id'] ]

    say(
      "I am #{name} (#{self.class}) from #{`uname -a`}...",
      '#test')
  end

  def on_message(data)

    typing(data['channel'])
    say("@#{user_name(data)} said: #{data['text'].inspect}", data['channel'])
  end
end

#ZeroBot.new(token: 'xxxx-111111111111-aaaaaaaaaaaaaaaaaaaaaaaa')
  # or
ZeroBot.new(token: 'test/.slack_api_token').run

license

MIT, see LICENSE.txt.