+
+ def seen(reg)
+ saw = case reg
+ when Struct::Saw
+ reg # for backwards compatibility
+ when Array
+ reg.last
+ end
+
+ if reg.kind_of? Array
+ before = reg.first
+ end
+
+ # TODO: a message should not be disclosed if:
+ # - it was said in a channel that was/is invite-only, private or secret
+ # - UNLESS the requester is also in the channel now, or the request is made
+ # in the channel?
+ msg_privacy = false
+ # TODO: a channel or it's topic should not be disclosed if:
+ # - the channel was/is private or secret
+ # - UNLESS the requester is also in the channel now, or the request is made
+ # in the channel?
+ chan_privacy = false
+
+ # What should be displayed for channel?
+ where = chan_privacy ? _(CHANPRIV_CHAN) : saw.where
+
+ formats = {
+ :normal => _(FORMAT_NORMAL),
+ :with_before => _(FORMAT_WITH_BEFORE)
+ }
+
+ if before && [:PART, :QUIT].include?(saw.type.to_sym) &&
+ [:PUBLIC, :ACTION].include?(before.type.to_sym)
+ # TODO see chan_privacy
+ prev_chan_privacy = false
+ prev_where = prev_chan_privacy ? _(CHANPRIV_CHAN) : before.where
+ did_before = case before.type.to_sym
+ when :PUBLIC
+ _(msg_privacy ? MSGPRIV_MSG_PUBLIC : MSG_PUBLIC)
+ when :ACTION
+ _(msg_privacy ? MSGPRIV_MSG_ACTION : MSG_ACTION)
+ end % {
+ :nick => saw.nick,
+ :message => before.message,
+ :where => prev_where
+ }
+
+ format = :with_before
+
+ time_diff = saw.time - before.time
+ if time_diff < 300
+ time_before = _("a moment")
+ elsif time_diff < 3600
+ time_before = _("a while")
+ else
+ format = :normal
+ end
+ else
+ format = :normal
+ end
+
+ nick = saw.nick