X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=lib%2Frbot%2Firc.rb;h=129f947e61d1d9d906e1b02d7b7e7deb486fd5f3;hb=4a86158144a13bc901222442ccd2db9c2bbd6bb0;hp=38c4a3e97061ba108d77baca201a2ce8700cc2e0;hpb=ad6fbb82f84bb5f5c9bd58dbce9e7f70ae43908b;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 38c4a3e9..129f947e 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -885,6 +885,8 @@ module Irc class User < Netmask alias :to_s :nick + attr_accessor :real_name + # Create a new IRC User from a given Netmask (or anything that can be converted # into a Netmask) provided that the given Netmask does not have globs. # @@ -894,6 +896,7 @@ module Irc raise ArgumentError, "#{str.inspect} must not have globs (unescaped * or ?)" if user.has_irc_glob? && user != "*" raise ArgumentError, "#{str.inspect} must not have globs (unescaped * or ?)" if host.has_irc_glob? && host != "*" @away = false + @real_name = String.new end # The nick of a User may be changed freely, but it must not contain glob patterns. @@ -971,15 +974,33 @@ module Irc end def modes_on(channel) - channel.modes_of(self) + case channel + when Channel + channel.modes_of(self) + else + return @server.channel(channel).modes_of(self) if @server + raise "Can't resolve channel #{channel}" + end end def is_op?(channel) - channel.has_op?(self) + case channel + when Channel + channel.has_op?(self) + else + return @server.channel(channel).has_op?(self) if @server + raise "Can't resolve channel #{channel}" + end end def is_voice?(channel) - channel.has_voice?(self) + case channel + when Channel + channel.has_voice?(self) + else + return @server.channel(channel).has_voice?(self) if @server + raise "Can't resolve channel #{channel}" + end end end @@ -1254,7 +1275,7 @@ module Irc # Checks if the receiver already has a user with the given _nick_ # def has_user?(nick) - user_nicks.index(nick.irc_downcase(casemap)) + @users.index(nick.to_irc_user(server_and_casemap)) end # Returns the user with nick _nick_, if available @@ -1268,8 +1289,8 @@ module Irc # def add_user(user, opts={}) silent = opts.fetch(:silent, false) - if has_user?(user) && !silent - warn "Trying to add user #{user} to channel #{self} again" + if has_user?(user) + warn "Trying to add user #{user} to channel #{self} again" unless silent else @users << user.to_irc_user(server_and_casemap) end