From: Giuseppe Bilotta Date: Sun, 1 Nov 2009 08:44:01 +0000 (+0100) Subject: Ruby 1.9 compat: use String#[0,1] for channel prefixes X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;h=34ca2ba507e4246f1bc1851b04d2ecdffd433a19;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git Ruby 1.9 compat: use String#[0,1] for channel prefixes This ensures that checks are correct in both Ruby 1.8 and 1.9 --- diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 7970a773..c893fc27 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -1381,7 +1381,7 @@ module Irc # def initialize(name, topic=nil, users=[], opts={}) raise ArgumentError, "Channel name cannot be empty" if name.to_s.empty? - warn "Unknown channel prefix #{name[0].chr}" if name !~ /^[&#+!]/ + warn "Unknown channel prefix #{name[0,1]}" if name !~ /^[&#+!]/ raise ArgumentError, "Invalid character in #{name.inspect}" if name =~ /[ \x07,]/ init_server_or_casemap(opts) @@ -1418,31 +1418,31 @@ module Irc # The channel prefix # def prefix - name[0].chr + name[0,1] end # A channel is local to a server if it has the '&' prefix # def local? - name[0] == 0x26 + name[0,1] == '&' end # A channel is modeless if it has the '+' prefix # def modeless? - name[0] == 0x2b + name[0,1] == '+' end # A channel is safe if it has the '!' prefix # def safe? - name[0] == 0x21 + name[0,1] == '!' end # A channel is normal if it has the '#' prefix # def normal? - name[0] == 0x23 + name[0,1] == '#' end # Create a new mode @@ -1818,7 +1818,7 @@ module Irc return ex else - prefix = name[0].chr + prefix = name[0,1] # Give a warning if the new Channel goes over some server limits. #