module Ruboty

Abstract class to be inherited from adapter class.

Constants

VERSION

Public Class Methods

actions() click to toggle source
# File lib/ruboty.rb, line 33
def actions
  handlers.map(&:actions).flatten.sort_by { |action| action.all? ? 1 : 0 }
end
die(message) click to toggle source
# File lib/ruboty.rb, line 23
def die(message)
  logger.error("Error: #{message}")
  exit(1)
end
handlers() click to toggle source
# File lib/ruboty.rb, line 28
def handlers
  []
end
logger() click to toggle source
# File lib/ruboty.rb, line 14
def logger
  @logger ||= begin
    $stdout.sync = true
    logger = Logger.new($stdout)
    logger.level = ENV["LOG_LEVEL"] ? ENV["LOG_LEVEL"].to_i : Logger::INFO
    logger
  end
end

Public Instance Methods

[](index) click to toggle source
# File lib/ruboty/message.rb, line 38
def [](index)
  match_data[index]
end
body() click to toggle source
# File lib/ruboty/message.rb, line 12
def body
  @original[:body]
end
from() click to toggle source
# File lib/ruboty/message.rb, line 16
def from
  @original[:from]
end
from_name() click to toggle source

@note Some chat service such as XMPP has 2 types of address, address and username @return [String] User identifier in the Chat service

# File lib/ruboty/message.rb, line 22
def from_name
  @original[:from_name] || from
end
match(pattern) click to toggle source
# File lib/ruboty/message.rb, line 34
def match(pattern)
  @match_data = pattern.match(body)
end
reply(body, options = {}) click to toggle source
# File lib/ruboty/message.rb, line 42
def reply(body, options = {})
  attributes = { body: body, from: to, to: from, original: original }.merge(options)
  robot.say(attributes)
end
robot() click to toggle source
# File lib/ruboty/message.rb, line 26
def robot
  @original[:robot]
end
to() click to toggle source
# File lib/ruboty/message.rb, line 30
def to
  @original[:to]
end