Class: Boty::DSL

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Logger
Defined in:
lib/boty/dsl.rb

Instance Attribute Summary collapse

Attributes included from Logger

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

adapter, adapter=, #log_error

Constructor Details

#initialize(bot) ⇒ DSL

Returns a new instance of DSL.



24
25
26
# File 'lib/boty/dsl.rb', line 24

def initialize(bot)
  @bot = bot
end

Instance Attribute Details

#botObject

Returns the value of attribute bot.



13
14
15
# File 'lib/boty/dsl.rb', line 13

def bot
  @bot
end

Class Method Details

.new(bot) ⇒ Object



20
21
22
# File 'lib/boty/dsl.rb', line 20

def self.new(bot)
  INSTANCES[bot] ||= original_constructor bot
end

.original_constructorObject



10
# File 'lib/boty/dsl.rb', line 10

alias_method :original_constructor, :new

Instance Method Details

#command(*args, &block) ⇒ Object



40
41
42
# File 'lib/boty/dsl.rb', line 40

def command(*args, &block)
  respond(*args, &block)
end

#hear(*args, &block) ⇒ Object



36
37
38
# File 'lib/boty/dsl.rb', line 36

def hear(*args, &block)
  match(*args, &block)
end

#httpObject



48
49
50
# File 'lib/boty/dsl.rb', line 48

def http
  @http ||= Boty::HTTP.new
end

#match_im(*args, &block) ⇒ Object



44
45
46
# File 'lib/boty/dsl.rb', line 44

def match_im(*args, &block)
  command(*args, &block)
end

#messageObject



28
29
30
# File 'lib/boty/dsl.rb', line 28

def message
  @bot.trigger_message
end

#message_from_me?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/boty/dsl.rb', line 32

def message_from_me?
  message.from? @bot
end