diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-06 13:54:27 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-04-06 13:54:27 +0000 |
commit | 9b03d79f79ac820a1940aa78d30302a83c9db160 (patch) | |
tree | 53b086121496ad788932291b1f5e7f5f3f447381 /lib | |
parent | 9db57bfc3d38cae306b6915140fc693811959ac9 (diff) |
New IRC Framework: topic setter should be a Netmask, not a User. Also improve display of Netmasks with unknown (generic) user/host components
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rbot/irc.rb | 15 | ||||
-rw-r--r-- | lib/rbot/rfc2812.rb | 8 |
2 files changed, 17 insertions, 6 deletions
diff --git a/lib/rbot/irc.rb b/lib/rbot/irc.rb index 45e14959..398f74d1 100644 --- a/lib/rbot/irc.rb +++ b/lib/rbot/irc.rb @@ -629,12 +629,19 @@ module Irc end
end
- # A Netmask is easily converted to a String for the usual representation
+ # A Netmask is easily converted to a String for the usual representation.
+ # We skip the user or host parts if they are "*", unless we've been asked
+ # for the full form
#
+ def to_s
+ ret = nick.dup
+ ret << "!" << user unless user == "*"
+ ret << "@" << host unless host == "*"
+ return ret
+ end
def fullform
"#{nick}!#{user}@#{host}"
end
- alias :to_s :fullform
# Converts the receiver into a Netmask with the given (optional)
# server/casemap association. We return self unless a conversion
@@ -900,7 +907,7 @@ module Irc # Checks if a User is well-known or not by looking at the hostname and user
#
def known?
- return nick!= "*" && user!="*" && host!="*"
+ return nick != "*" && user != "*" && host != "*"
end
# Is the user away?
@@ -1164,7 +1171,7 @@ module Irc #
def initialize(text="", set_by="", set_on=Time.new)
@text = text
- @set_by = set_by.to_irc_user
+ @set_by = set_by.to_irc_netmask
@set_on = set_on
end
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index f11fd6bc..5174203f 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -1001,11 +1001,15 @@ module Irc when RPL_TOPIC_INFO data[:nick] = @server.user(argv[0]) data[:channel] = @server.get_channel(argv[1]) - data[:source] = @server.user(argv[2]) + + # This must not be an IRC::User because it might not be an actual User, + # and we risk overwriting valid User data + data[:source] = argv[2].to_irc_netmask(:server => @server) + data[:time] = Time.at(argv[3].to_i) if data[:channel] - data[:channel].topic.set_by = data[:nick] + data[:channel].topic.set_by = data[:source] data[:channel].topic.set_on = data[:time] else warning "Received topic #{data[:topic].inspect} for channel #{data[:channel].inspect} I was not on" |