Module: Jabbot::Macros

Defined in:
lib/jabbot/macros.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(mod) ⇒ Object



9
10
11
# File 'lib/jabbot/macros.rb', line 9

def self.included(mod)
  @@bot = nil
end

Instance Method Details

#clientObject



39
40
41
# File 'lib/jabbot/macros.rb', line 39

def client
  bot.client
end

#closeObject Also known as: quit



43
44
45
# File 'lib/jabbot/macros.rb', line 43

def close
  bot.close
end

#configure(&blk) ⇒ Object



13
14
15
# File 'lib/jabbot/macros.rb', line 13

def configure(&blk)
  bot.configure(&blk)
end

#join(options = {}, &blk) ⇒ Object



26
27
28
# File 'lib/jabbot/macros.rb', line 26

def join(options = {}, &blk)
  add_handler(:join, /\Ajoin\Z/, options, &blk)
end

#leave(options = {}, &blk) ⇒ Object



30
31
32
# File 'lib/jabbot/macros.rb', line 30

def leave(options = {}, &blk)
  add_handler(:leave, /\Aleave\Z/, options, &blk)
end

#message(pattern = nil, options = {}, &blk) ⇒ Object



17
18
19
# File 'lib/jabbot/macros.rb', line 17

def message(pattern = nil, options = {}, &blk)
  add_handler(:message, pattern, options, &blk)
end

#post(msg, to = nil) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/jabbot/macros.rb', line 52

def post(msg, to=nil)
  if msg.is_a?(Hash) && msg.keys.size == 1
    to = msg.values.first
    msg = msg.keys.first
  end
  bot.send_message(msg, to)
end

#query(pattern = nil, options = {}, &blk) ⇒ Object Also known as: private_message



21
22
23
# File 'lib/jabbot/macros.rb', line 21

def query(pattern = nil, options = {}, &blk)
  add_handler(:private, pattern, options, &blk)
end

#run?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/jabbot/macros.rb', line 60

def run?
  !@@bot.nil?
end

#subject(pattern = nil, options = {}, &blk) ⇒ Object Also known as: topic



34
35
36
# File 'lib/jabbot/macros.rb', line 34

def subject(pattern = nil, options = {}, &blk)
  add_handler(:subject, pattern, options, &blk)
end

#userObject



48
49
50
# File 'lib/jabbot/macros.rb', line 48

def user
  bot.user
end