diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-08-05 13:08:02 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2006-08-05 13:08:02 +0000 |
commit | 0d0f61e6e3185488c85a6805ff2f4d468d4a3935 (patch) | |
tree | bbabe12e3586afa8075e79c92ccc7d2309cabd3b /lib | |
parent | 27a1965cc7b57e9de6d69504faaa3915a7cc959e (diff) |
Fix user data not being upgraded and fix a bug in the login-by-mask code
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/botuser.rb | 2 | ||||
-rw-r--r-- | lib/rbot/irc.rb | 33 | ||||
-rw-r--r-- | lib/rbot/ircbot.rb | 5 |
3 files changed, 28 insertions, 12 deletions
diff --git a/lib/rbot/botuser.rb b/lib/rbot/botuser.rb index 5cb05f17..a6a3bf4a 100644 --- a/lib/rbot/botuser.rb +++ b/lib/rbot/botuser.rb @@ -316,7 +316,7 @@ module Irc # is right. If it is, the Netmask of the user is added to the
# list of acceptable Netmask unless it's already matched.
def login(user, password)
- if password == @password or (@password.nil? and @login_by_mask and knows?(user))
+ if password == @password or (password.nil? and @login_by_mask and knows?(user))
add_netmask(user) unless knows?(user)
debug "#{user} logged in as #{self.inspect}"
return true
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 21c72264..8ef55712 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -84,11 +84,18 @@ module Irc @key.to_s
end
+ # Two Casemaps are equal if they have the same upper and lower ranges
+ #
+ def ==(arg)
+ other = arg.to_irc_casemap
+ return self.upper == other.upper && self.lower == other.lower
+ end
+
# Raise an error if _arg_ and self are not the same Casemap
#
def must_be(arg)
other = arg.to_irc_casemap
- raise "Casemap mismatch (#{self} != #{other})" unless self == other
+ raise "Casemap mismatch (#{self.inspect} != #{other.inspect})" unless self == other
return true
end
@@ -616,10 +623,15 @@ module Irc #
def matches?(arg)
cmp = arg.to_irc_netmask(:casemap => casemap)
+ debug "Matching #{self.fullform} against #{arg.fullform}"
[:nick, :user, :host].each { |component|
us = self.send(component).irc_downcase(casemap)
them = cmp.send(component).irc_downcase(casemap)
- raise NotImplementedError if us.has_irc_glob? && them.has_irc_glob?
+ if us.has_irc_glob? && them.has_irc_glob?
+ next if us == them
+ warn NotImplementedError
+ return false
+ end
return false if us.has_irc_glob? && !them.has_irc_glob?
return false unless us =~ them.to_irc_regexp
}
@@ -774,14 +786,14 @@ module Irc def replace(other)
case other
when User
- nick = other.nick
- user = other.user
- host = other.host
+ self.nick = other.nick
+ self.user = other.user
+ self.host = other.host
@server = other.server
@casemap = other.casemap unless @server
- @away = other.away
+ @away = other.away?
else
- replace(other.to_irc_user(server_and_casemap))
+ self.replace(other.to_irc_user(server_and_casemap))
end
end
@@ -1506,17 +1518,20 @@ module Irc def new_user(str, fails=true)
tmp = str.to_irc_user(:server => self)
old = get_user(tmp.nick)
+ # debug "Tmp: #{tmp.inspect}"
+ # debug "Old: #{old.inspect}"
if old
# debug "User already existed as #{old.inspect}"
if tmp.known?
if old.known?
+ # debug "Both were known"
# Do not raise an error: things like Freenode change the hostname after identification
warning "User #{tmp.nick} has inconsistent Netmasks! #{self} knows #{old.inspect} but access was tried with #{tmp.inspect}" if old != tmp
raise "User #{tmp} already exists on server #{self}" if fails
end
- if old != tmp
+ if old.fullform.downcase != tmp.fullform.downcase
old.replace(tmp)
- # debug "User improved to #{old.inspect}"
+ # debug "Known user now #{old.inspect}"
end
end
return old
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index f5250b9b..3bfd8b9e 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -408,8 +408,9 @@ class IrcBot } @client[:privmsg] = proc { |data| m = PrivMessage.new(self, server, data[:source], data[:target], data[:message]) - debug "Message target is #{data[:target].inspect}" - debug "Bot is #{myself.inspect}" + # debug "Message source is #{data[:source].inspect}" + # debug "Message target is #{data[:target].inspect}" + # debug "Bot is #{myself.inspect}" # TODO use the new Netmask class # @config['irc.ignore_users'].each { |mask| return if Irc.netmaskmatch(mask,m.source) } |