From 34ca2ba507e4246f1bc1851b04d2ecdffd433a19 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sun, 1 Nov 2009 09:44:01 +0100 Subject: 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 --- lib/rbot/irc.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'lib/rbot') 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. # -- cgit v1.2.3