module Ellen

Abstract class to be inherited from adapter class.

Constants

VERSION

Public Class Methods

actions() click to toggle source
# File lib/ellen.rb, line 27
def actions
  handlers.map(&:actions).flatten.sort_by(&:all?)
end
die(message) click to toggle source
# File lib/ellen.rb, line 17
def die(message)
  logger.error("Error: #{message}")
  exit(1)
end
handlers() click to toggle source
# File lib/ellen.rb, line 22
def handlers
  []
end
logger() click to toggle source
# File lib/ellen.rb, line 13
def logger
  @logger ||= Ellen::Logger.new($stdout)
end

Public Instance Methods

[](index) click to toggle source
# File lib/ellen/message.rb, line 38
def [](index)
  match_data[index]
end
body() click to toggle source
# File lib/ellen/message.rb, line 12
def body
  @original[:body]
end
from() click to toggle source
# File lib/ellen/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/ellen/message.rb, line 22
def from_name
  @original[:from_name] || from
end
match(pattern) click to toggle source
# File lib/ellen/message.rb, line 34
def match(pattern)
  @match_data = pattern.match(body)
end
reply(body, options = {}) click to toggle source
# File lib/ellen/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/ellen/message.rb, line 26
def robot
  @original[:robot]
end
to() click to toggle source
# File lib/ellen/message.rb, line 30
def to
  @original[:to]
end