ret << ' plainmessage=' << plainmessage.inspect
ret << fields if fields
ret << ' (identified)' if identified?
- ret << ' (addressed to me)' if identified?
+ ret << ' (addressed to me)' if address?
ret << ' (replied)' if replied?
ret << ' (ignored)' if ignored?
ret << ' (in thread)' if in_thread?
@plainmessage = BasicUserMessage.strip_formatting(@message)
@message = BasicUserMessage.strip_initial_formatting(@message)
- if target && target == @bot.myself
- @address = true
- end
+ @address = true if source == @bot.myself
end
return @address
end
- # has this message been replied to by a plugin?
- def replied?
- return @replied
- end
-
# strip mIRC colour escapes from a string
def BasicUserMessage.stripcolour(string)
return "" unless string
@ctcp = false
@action = false
- if target == @bot.myself
+ if @address = (target == @bot.myself)
@private = true
- @address = true
@channel = nil
@replyto = source
else
@action = @ctcp == 'ACTION'
debug "Received CTCP command #{@ctcp} with options #{@message} (action? #{@action})"
@logmessage = @message.dup
+ @plainmessage = BasicUserMessage.strip_formatting(@message)
+ @message = BasicUserMessage.strip_initial_formatting(@message)
end
# free splitting for plugins
# class to manage IRC PRIVMSGs
class PrivMessage < UserMessage
- def initialize(bot, server, source, target, message)
- @msg_wants_id = true
- super
+ def initialize(bot, server, source, target, message, opts={})
+ @msg_wants_id = opts[:handle_id]
+ super(bot, server, source, target, message)
end
end
# class to manage IRC NOTICEs
class NoticeMessage < UserMessage
- def initialize(bot, server, source, target, message)
- @msg_wants_id = true
- super
+ def initialize(bot, server, source, target, message, opts={})
+ @msg_wants_id = opts[:handle_id]
+ super(bot, server, source, target, message)
end
end
attr_accessor :modes
def initialize(bot, server, source, target, message="")
super(bot, server, source, target, message)
- @address = (source == @bot.myself)
@modes = []
end
end
end
+ # class to manage WHOIS replies
+ class WhoisMessage < BasicUserMessage
+ attr_reader :whois
+ def initialize(bot, server, source, target, whois)
+ super(bot, server, source, target, "")
+ @whois = whois
+ end
+
+ def inspect
+ fields = ' whois=' << whois.inspect
+ super(fields)
+ end
+ end
+
# class to manage NAME replies
class NamesMessage < BasicUserMessage
attr_accessor :users
super(bot, server, source, channel, message)
@channel = channel
# in this case sourcenick is the nick that could be the bot
- @address = (source == @bot.myself)
end
end