Module: Jabbot::Macros
- Defined in:
- lib/jabbot/macros.rb
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
- #close ⇒ Object (also: #quit)
- #configure(&blk) ⇒ Object
- #join(options = {}, &blk) ⇒ Object
- #leave(options = {}, &blk) ⇒ Object
- #message(pattern = nil, options = {}, &blk) ⇒ Object
- #post(msg, to = nil) ⇒ Object
- #query(pattern = nil, options = {}, &blk) ⇒ Object (also: #private_message)
- #run? ⇒ Boolean
- #subject(pattern = nil, options = {}, &blk) ⇒ Object (also: #topic)
- #user ⇒ Object
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
#client ⇒ Object
39 40 41 |
# File 'lib/jabbot/macros.rb', line 39 def client bot.client end |
#close ⇒ Object 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( = {}, &blk) add_handler(:join, /\Ajoin\Z/, , &blk) end |
#leave(options = {}, &blk) ⇒ Object
30 31 32 |
# File 'lib/jabbot/macros.rb', line 30 def leave( = {}, &blk) add_handler(:leave, /\Aleave\Z/, , &blk) end |
#message(pattern = nil, options = {}, &blk) ⇒ Object
17 18 19 |
# File 'lib/jabbot/macros.rb', line 17 def (pattern = nil, = {}, &blk) add_handler(:message, pattern, , &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.(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, = {}, &blk) add_handler(:private, pattern, , &blk) end |
#run? ⇒ 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, = {}, &blk) add_handler(:subject, pattern, , &blk) end |
#user ⇒ Object
48 49 50 |
# File 'lib/jabbot/macros.rb', line 48 def user bot.user end |