Class: IrcMachine::Core

Inherits:
Plugin::Base show all
Defined in:
lib/irc_machine/core.rb

Instance Attribute Summary

Attributes inherited from Plugin::Base

#session

Instance Method Summary collapse

Methods inherited from Plugin::Base

#initialize

Constructor Details

This class inherits a constructor from IrcMachine::Plugin::Base

Instance Method Details

#connectedObject



4
5
6
7
8
9
10
11
12
# File 'lib/irc_machine/core.rb', line 4

def connected
  session.password options.password unless options.password.nil?
  session.user options.user, options.realname
  session.nick options.nick
  session.state.nick = options.nick
  EM::add_timer(5) do
    options.channels.each { |c| session.join *c.split } if options.channels
  end
end

#receive_line(line) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/irc_machine/core.rb', line 18

def receive_line(line)

  puts "[core] << #{line}" if options.verbose

  case line

  when /^PING (.*)/
    session.raw "PONG #{$1}"

  when /^:#{self_pattern} JOIN :(\S+)/
    channels << $1

  when /^:#{self_pattern} PART :(\S+)/
    channels.delete $1

  when /^:\S+ 475 \S+ (\S+) :(.*)$/
    puts "[core] #{$1}: #{$2}"

  end
end

#terminateObject



14
15
16
# File 'lib/irc_machine/core.rb', line 14

def terminate
  session.quit "shutting down"
end