Class: IRC::Callback::CallbackDSL

Inherits:
Object
  • Object
show all
Includes:
IRC::Commands
Defined in:
lib/on_irc/callback.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from IRC::Commands

#join, #notice, #part, #pong, #privmsg

Constructor Details

#initialize(irc, event) ⇒ CallbackDSL

Returns a new instance of CallbackDSL.



17
18
19
20
# File 'lib/on_irc/callback.rb', line 17

def initialize(irc, event)
  @event = event
  @irc = irc
end

Class Method Details

.run(irc, event, block) ⇒ Object



12
13
14
15
# File 'lib/on_irc/callback.rb', line 12

def self.run(irc, event, block)
  callbackdsl = self.new(irc, event)
  block.arity < 1 ? callbackdsl.instance_eval(&block) : block.call(callbackdsl)
end

Instance Method Details

#commandObject



27
28
29
# File 'lib/on_irc/callback.rb', line 27

def command
  @event.command
end

#paramsObject



35
36
37
# File 'lib/on_irc/callback.rb', line 35

def params
  @event.params
end

#respond(message) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/on_irc/callback.rb', line 46

def respond(message)
  if params[0].start_with? '#'
    privmsg(params[0], message)
  else
    privmsg(sender.nick, message)
  end
end

#send_cmd(cmd, *args) ⇒ Object



42
43
44
# File 'lib/on_irc/callback.rb', line 42

def send_cmd(cmd, *args)
  @event.server.send_cmd(cmd, *args)
end

#senderObject



23
24
25
# File 'lib/on_irc/callback.rb', line 23

def sender
  @event.sender
end

#serverObject



31
32
33
# File 'lib/on_irc/callback.rb', line 31

def server
  @event.server
end