Class: Coffeemaker::Bot::Irc

Inherits:
Object
  • Object
show all
Defined in:
lib/coffeemaker/bot/irc.rb,
lib/coffeemaker/bot/irc/message.rb,
lib/coffeemaker/bot/irc/commands.rb,
lib/coffeemaker/bot/irc/connection.rb

Defined Under Namespace

Modules: Commands, Connection Classes: Message

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Irc

Returns a new instance of Irc.



14
15
16
17
18
19
20
21
22
23
# File 'lib/coffeemaker/bot/irc.rb', line 14

def initialize(options)
  @host       = options.delete(:irc_host)
  @port       = options.delete(:irc_port)
  @nick       = options.delete(:nick)
  @pass       = options.delete(:pass)
  @user       = options.delete(:user)
  @on_message = options.delete(:on_message)
  @logger     = options.delete(:logger)
  @ssl        = options.delete(:ssl)
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def host
  @host
end

#loggerObject (readonly)

Returns the value of attribute logger.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def logger
  @logger
end

#nickObject (readonly)

Returns the value of attribute nick.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def nick
  @nick
end

#on_connectObject

Returns the value of attribute on_connect.



8
9
10
# File 'lib/coffeemaker/bot/irc.rb', line 8

def on_connect
  @on_connect
end

#on_messageObject

Returns the value of attribute on_message.



8
9
10
# File 'lib/coffeemaker/bot/irc.rb', line 8

def on_message
  @on_message
end

#passObject (readonly)

Returns the value of attribute pass.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def pass
  @pass
end

#portObject (readonly)

Returns the value of attribute port.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def port
  @port
end

#userObject (readonly)

Returns the value of attribute user.



9
10
11
# File 'lib/coffeemaker/bot/irc.rb', line 9

def user
  @user
end

Instance Method Details

#startObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/coffeemaker/bot/irc.rb', line 25

def start
  @connection = EM.connect(@host, @port, Connection) do |c|
    c.host       = @host
    c.port       = @port
    c.pass       = @pass
    c.user       = @user
    c.nick       = @nick
    c.on_message = @on_message
    c.on_connect = @on_connect
    c.logger     = @logger
    c.ssl        = @ssl
  end
end

#stopObject



39
40
41
# File 'lib/coffeemaker/bot/irc.rb', line 39

def stop
  @connection.close_connection
end