Class: Rlyeh::Target

Inherits:
Object
  • Object
show all
Defined in:
lib/rlyeh/target.rb

Instance Method Summary collapse

Constructor Details

#initialize(env, target) ⇒ Target

Returns a new instance of Target.



3
4
5
6
# File 'lib/rlyeh/target.rb', line 3

def initialize(env, target)
  @env = env
  @target = target
end

Instance Method Details

#notice(text, prefix = nil) ⇒ Object



23
24
25
# File 'lib/rlyeh/target.rb', line 23

def notice(text, prefix = nil)
  send_message 'NOTICE', text, prefix
end

#privmsg(text, prefix = nil) ⇒ Object



19
20
21
# File 'lib/rlyeh/target.rb', line 19

def privmsg(text, prefix = nil)
  send_message 'PRIVMSG', text, prefix
end

#send_message(command, text, prefix) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/rlyeh/target.rb', line 8

def send_message(command, text, prefix)
  prefix = {:nick => prefix.to_s} unless prefix.is_a?(Hash)
  unless prefix.key? :servername
    prefix[:nick] ||= 'rlyeh'
    prefix[:user] ||= 'rlyeh'
    prefix[:host] ||= @env.settings.server_name
  end

  @env.connection.send_message command, @target, ":#{text}", :prefix => prefix
end