Sha256: 00e6849ba4fd8cd0db86da288184233ed03fd1752c7604e9dd1c010bb7d763a0
Contents?: true
Size: 1.69 KB
Versions: 1
Compression:
Stored size: 1.69 KB
Contents
require 'rflow/components/irc/extensions' require 'rflow/components/irc/client' class RFlow module Components module IRC # Load the schemas SCHEMA_DIRECTORY = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', '..', 'schema')) SCHEMA_FILES = { 'irc_message.avsc' => 'RFlow::Message::Data::IRC::Message', } SCHEMA_FILES.each do |file_name, data_type_name| schema_string = ::File.read(::File.join(SCHEMA_DIRECTORY, file_name)) RFlow::Configuration.add_available_data_type data_type_name, 'avro', schema_string end # Load the data extensions RFlow::Configuration.add_available_data_extension('RFlow::Message::Data::IRC::Message', RFlow::Components::IRC::Extensions::IRCMessageExtension) # Some useful IRC parsing methods IRC_LINE_REGEX = /^(?::(\S+) )?(\S+)(?: (.+))?$/ IRC_PREFIX_REGEX = /^([^!]+)(?:!([^@]+))?(?:@(.*)+)?$/ def self.parse_irc_line(line) match = IRC_LINE_REGEX.match(line) unless match RFlow.logger.error "Error parsing IRC line '#{line}'" return end prefix, cmd, param_string = match[1..3] param_string, trailing_param = param_string.split(' :', 1) params = param_string.split(' ') params << trailing_param if trailing_param [prefix, cmd, params] end def self.parse_irc_prefix(prefix) match = IRC_PREFIX_REGEX.match(prefix) unless match RFlow.logger.error "Error parsing IRC prefix '#{prefix}'" return end # nick/server, user, host match[1..3] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rflow-components-irc-0.0.2 | lib/rflow/components/irc.rb |