Show
Ignore:
Timestamp:
03/15/10 00:08:48 (6 months ago)
Author:
Robin H. Johnson <robbat2@…>
Children:
6d112bb9364e9329806c90f116ac30e3f1437a0c
Parents:
eb3e6265ef371eda4594f59c872fbb68e1998441
git-author:
Robin H. Johnson <robbat2@gentoo.org> 1268473477 +0000
git-committer:
Robin H. Johnson <robbat2@gentoo.org> 1268600928 +0000
Message:

seen: Introduce framework for message and channel privacy.

This commit introduces the ability to note that a user was doing
something, optionally without disclosing what or where it was.

Users themselves do not get the chance to be hidden, because you can ask
the /WHOIS service if they logged on at all.

Signed-off-by: Robin H. Johnson <robbat2@…>

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • data/rbot/plugins/seen.rb

    reb3e626 rd7cdc2a  
    99 
    1010class SeenPlugin < Plugin 
     11 
     12  MSG_PUBLIC = N_("saying \"%{message}\" in %{where}") 
     13  MSG_ACTION = N_("doing *%{nick} %{message}* in %{where}") 
     14  MSG_NICK = N_("changing nick from %{nick} to %{message}") 
     15  MSG_PART = N_("leaving %{where} (%{message})") 
     16  MSG_PART_EMPTY = N_("leaving %{where}") 
     17  MSG_JOIN = N_("joining %{where}") 
     18  MSG_QUIT = N_("quitting IRC (%{message})") 
     19  MSG_TOPIC = N_("changing the topic of %{where} to \"%{message}\"") 
     20 
     21  CHANPRIV_CHAN      = N_("a private channel") 
     22  CHANPRIV_MSG_TOPIC  = N_("changing the topic of %{where}") 
     23 
     24  MSGPRIV_MSG_PUBLIC = N_("speaking in %{where}") 
     25  MSGPRIV_MSG_ACTION = N_("doing something in %{where}") 
     26 
     27  FORMAT_NORMAL = N_("%{nick} was last seen %{when}, %{doing}") 
     28  FORMAT_WITH_BEFORE = N_("%{nick} was last seen %{when}, %{doing} and %{time} before %{did_before}") 
     29 
    1130  Config.register Config::IntegerValue.new('seen.max_results', 
    1231    :default => 3, :validate => Proc.new{|v| v >= 0}, 
     
    86105    end 
    87106 
     107    # TODO: a message should not be disclosed if: 
     108    # - it was said in a channel that was/is invite-only, private or secret 
     109    # - UNLESS the requester is also in the channel now, or the request is made 
     110    #   in the channel? 
     111    msg_privacy = false 
     112    # TODO: a channel or it's topic should not be disclosed if: 
     113    # - the channel was/is private or secret 
     114    # - UNLESS the requester is also in the channel now, or the request is made 
     115    #   in the channel? 
     116    chan_privacy = false 
     117 
     118    # What should be displayed for channel? 
     119    where = chan_privacy ? _(CHANPRIV_CHAN) : saw.where 
     120 
    88121    formats = { 
    89       :normal      => _("%{nick} was last seen %{when}, %{doing}"), 
    90       :with_before => _("%{nick} was last seen %{when}, %{doing} and %{time} before %{did_before}") 
     122      :normal      => _(FORMAT_NORMAL), 
     123      :with_before => _(FORMAT_WITH_BEFORE) 
    91124    } 
    92125 
     
    95128      did_before = case before.type.to_sym 
    96129      when :PUBLIC 
    97         _("saying \"%{message}\"") 
     130        _(msg_privacy ? MSGPRIV_MSG_PUBLIC : MSG_PUBLIC) 
    98131      when :ACTION 
    99         _("doing *%{nick} %{message}*") 
     132        _(msg_privacy ? MSGPRIV_MSG_ACTION : MSG_ACTION) 
    100133      end % { 
    101134        :nick => saw.nick, 
    102         :message => before.message 
     135        :message => before.message, 
     136        :where => where 
    103137      } 
    104138 
     
    128162    doing = case saw.type.to_sym 
    129163    when :PUBLIC 
    130       _("saying \"%{message}\" in %{where}") 
     164      _(msg_privacy ? MSGPRIV_MSG_PUBLIC : MSG_PUBLIC) 
    131165    when :ACTION 
    132       _("doing *%{nick} %{message}* in %{where}") 
     166      _(msg_privacy ? MSGPRIV_MSG_ACTION : MSG_ACTION) 
    133167    when :NICK 
    134       _("changing nick from %{nick} to %{message}") 
     168      _(MSG_NICK) 
    135169    when :PART 
    136170      if saw.message.empty? 
    137         _("leaving %{where}") 
     171        _(MSG_PART_EMPTY) 
    138172      else 
    139         _("leaving %{where} (%{message})") 
     173        _(MSG_PART) 
    140174      end 
    141175    when :JOIN 
    142       _("joining %{where}") 
     176      _(MSG_JOIN) 
    143177    when :QUIT 
    144       _("quitting IRC (%{message})") 
     178      _(MSG_QUIT) 
    145179    when :TOPIC 
    146       _("changing the topic of %{where} to \"%{message}\"") 
    147     end % { :message => saw.message, :where => saw.where, :nick => saw.nick } 
     180      _(chan_privacy ? CHANPRIV_MSG_TOPIC : MSG_TOPIC) 
     181    end % { :message => saw.message, :where => where, :nick => saw.nick } 
    148182 
    149183    case format 
     
    166200 
    167201  def store(m, saw) 
     202    # TODO: we need to store the channel state INVITE/SECRET/PRIVATE here, in 
     203    # some symbolic form, so that we know the prior state of the channel when 
     204    # it comes time to display. 
    168205    reg = @registry[saw.nick] 
    169206