/usr/lib/ruby/vendor_ruby/net/irc.rb is in ruby-net-irc 0.0.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!ruby
require "ostruct"
require "socket"
require "logger"
require "monitor"
module Net; end
module Net::IRC
VERSION = "0.0.9".freeze
class IRCException < StandardError; end
require "net/irc/constants"
require "net/irc/pattern"
autoload :Message, "net/irc/message"
autoload :Client, "net/irc/client"
autoload :Server, "net/irc/server"
class Prefix < String
def nick
extract[0]
end
def user
extract[1]
end
def host
extract[2]
end
# Extract Prefix String to [nick, user, host] Array.
def extract
_, *ret = *self.match(/\A([^\s!]+)(?:!([^\s@]+)@(\S+))?\z/)
ret
end
end
# Encode to CTCP message. Prefix and postfix \x01.
def ctcp_encode(str)
"\x01#{ctcp_quote(str)}\x01"
end
#alias :ctcp_encoding :ctcp_encode
module_function :ctcp_encode #, :ctcp_encoding
# Decode from CTCP message delimited with \x01.
def ctcp_decode(str)
ctcp_dequote(str.delete("\x01"))
end
#alias :ctcp_decoding :ctcp_decode
module_function :ctcp_decode #, :ctcp_decoding
def ctcp_quote(str)
low_quote(str.gsub("\\", "\\\\\\\\").gsub("\x01", "\\a"))
end
module_function :ctcp_quote
def ctcp_dequote(str)
low_dequote(str).gsub("\\a", "\x01").gsub(/\\(.|\z)/m, "\\1")
end
module_function :ctcp_dequote
private
def low_quote(str)
str.gsub("\x10", "\x10\x10").gsub("\x00", "\x10\x30").gsub("\r", "\x10r").gsub("\n", "\x10n")
end
def low_dequote(str)
str.gsub("\x10n", "\n").gsub("\x10r", "\r").gsub("\x10\x30", "\x00").gsub("\x10\x10", "\x10")
end
end
|