Class: Syndi::IRC::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/syndi/irc/common.rb

Overview

A class which manages such common IRC functions as syndijoining channels, and identifying to services the traditional PRIVMSG way.

Instance Method Summary collapse

Constructor Details

#initialize(lib) ⇒ Common

Construct a new common function handler.

Parameters:



15
16
17
18
19
# File 'lib/syndi/irc/common.rb', line 15

def initialize lib
  @lib = lib
  $m.events.on   :die,       &method(:do_die)
  @lib.events.on :connected, &method(:do_syndijoin)
end

Instance Method Details

#do_die(reason) ⇒ Object

Disconnect from servers on termination.

Parameters:

  • reason (String)

    Reason for termination.



53
54
55
# File 'lib/syndi/irc/common.rb', line 53

def do_die reason
  @lib.connections.each { |net, irc| irc.disconnect reason }
end

#do_identify(irc) ⇒ Object

Automatically identify with services the traditional way, which is to say by a /msg.

Parameters:



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/syndi/irc/common.rb', line 25

def do_identify irc
  if $m.conf['irc'][irc.s]['nickIdentify']
    
    # Assume the service is NickServ if not specified
    service = $m.conf['irc'][irc.s]['nickIdentify']['service'] || 'NickServ'
    # and assume the command is IDENTIFY if not specified
    command = $m.conf['irc'][irc.s]['nickIdentify']['command'] || 'IDENTIFY'

    # we can't actually /msg anyone yet.....
  end
end

#do_syndijoin(irc) ⇒ Object

Automatically join IRC channels upon connection.

Parameters:



40
41
42
43
44
45
46
47
48
# File 'lib/syndi/irc/common.rb', line 40

def do_syndijoin irc
  if $m.conf['irc'][irc.s]['syndijoin']
    
    $m.conf['irc'][irc.s]['syndijoin'].each do |chan|
      irc.join(chan['name'], chan['key']||nil)
    end

  end
end