class Syndi::IRC::Common
A class which manages such common IRC
functions as syndijoining channels, and identifying to services the traditional PRIVMSG way.
Public Class Methods
new(lib)
click to toggle source
Construct a new common function handler.
@param [Syndi::IRC::Library] lib The IRC
library instance.
# 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
Public Instance Methods
do_die(reason)
click to toggle source
Disconnect from servers on termination.
@param [String] reason Reason for termination.
# File lib/syndi/irc/common.rb, line 53 def do_die reason @lib.connections.each { |net, irc| irc.disconnect reason } end
do_identify(irc)
click to toggle source
Automatically identify with services the traditional way, which is to say by a /msg.
@param [Syndi::IRC::Server] irc The IRC
connection.
# 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)
click to toggle source
Automatically join IRC
channels upon connection.
@param [Syndi::IRC::Server] irc The IRC
connection.
# 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