diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-10 09:59:15 +0000 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2007-02-10 09:59:15 +0000 |
commit | aeff57ecf846b714e08d0095f1aea28a74e47d0b (patch) | |
tree | b62243102201ce96b727ee93e81c89ad0944ddf1 /lib/rbot | |
parent | d0cc020ed8f97230e438ca611a2123cf72f085a0 (diff) |
Handle server connections (e.g. through a bip proxy) that do not use the full user hostmask as a prefix of user messages
Diffstat (limited to 'lib/rbot')
-rw-r--r-- | lib/rbot/rfc2812.rb | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/rbot/rfc2812.rb b/lib/rbot/rfc2812.rb index 900c750d..9ca6571a 100644 --- a/lib/rbot/rfc2812.rb +++ b/lib/rbot/rfc2812.rb @@ -886,16 +886,27 @@ module Irc prefix, command, params = $2, $3, $5 if prefix != nil - data[:source] = prefix - if prefix =~ /^(\S+)!(\S+)$/ + # Most servers will send a full nick!user@host prefix for + # messages from users. Therefore, when the prefix doesn't match this + # syntax it's usually the server hostname. + # + # This is not always true, though, since some servers do not send a + # full hostmask for user messages. + # + if prefix =~ /^(?:\S+)(?:!\S+)?@(?:\S+)$/ data[:source] = @server.user(prefix) else - if @server.hostname && @server.hostname != data[:source] - warning "Unknown origin #{data[:source]} for message\n#{serverstring.inspect}" + if @server.hostname + if @server.hostname != prefix + debug "Origin #{prefix} for message\n\t#{serverstring.inspect}\nis neither a user hostmask nor the server hostname, assuming it's a nick" + data[:source] = @server.user(prefix) + else + data[:source] = @server + end else @server.instance_variable_set(:@hostname, data[:source]) + data[:source] = @server end - data[:source] = @server end end |