Archive of RubyForge sup-talk mailing list
 help / color / mirror / Atom feed
From: Philippe LeCavalier <support@plecavalier.com>
To: Hamish D <dmishd@gmail.com>
Cc: sup-talk <sup-talk@rubyforge.org>
Subject: Re: [sup-talk] best method for before-add-message.rb
Date: Sun, 13 Feb 2011 13:08:23 -0500	[thread overview]
Message-ID: <1297619496-sup-5791@plc.intranet.plecavalier.com> (raw)
In-Reply-To: <AANLkTim2ULBn=c8pPqSQ49i661HRmGgZbrevKix9kbSV@mail.gmail.com>

Excerpts from Hamish D's message of Sun Feb 13 12:12:15 -0500 2011:
> > what would be the best way to match - for instance - the List-Id-Header in case
> > it's present? I've been wondering about this for a long time, right now, I'm
> > matching the raw-header against some regex, but it breaks if the line I'm
> > matching contains a newline (i.e. the header field is longer than one line).
> 
> Is there any reason you're not using the list_address member of
> message? It is derived from the List-Post header if present, or if
> not, the X-Mailing-List header. You can use it as, for example:
> 
> # Mark by email list
> if message.list_address.email =~ /sup-talk/
>   message.add_label "sup"
>   message.add_label "list"
> end
> 
> Hamish
I tried that and experienced varying success.
ie 2 or three 'add_label' is fine but adding and removing, for instance doesn't appear possible. I would assume most ppl here are interested in not only applying a label but also removing one in particular the inbox label.

Is anybody successfully both adding and removing a labels...in any way regexp, header...anything?

So far I've tried this:
addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r")
if ! addressfile.grep(/#{message.list_address.email}/).empty?
  message.add_label :lists
end
addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r")
if ! addressfile.grep(/#{message.list_address.email}/).empty?
  message.remove_label :inbox
end

In this case it appears handling a msg twice breaks everything. So then I tried this:

case message.list_address
  when /samba@lists.samba.org/
    message.add_label :lists
    message.add_label :samba
    message.remove_label :inbox
  when /cups@easysw.com/
    message.add_label :lists
    message.add_label :cups
    message.remove_label :inbox
end

This remains the closest I've come -thanks to Mark Alexander-. In this I was able to get multiple labels going for multiple msgs but again, very much hit-and-miss for label removal. I should probably not that message.remove_label in it's simplest form works fine. Just appears that it can't live alongside any other function.

I think we're starting to see that unless one is conversely adept in one form of language or another your odds of successfully adding labels upon receipt are in a manner which will create a robust searching db is quite low. Thus defeating in part the whole concept of this system. Don't mean to sound so negative here but I just to point out that from a none fluent regex/rudy....etc the wiki and mail archives leave you somewhat hanging.
-- 
Thanks,
Phil
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk


      reply	other threads:[~2011-02-13 18:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-10 14:44 Philippe LeCavalier
2011-02-10 16:40 ` Mark Alexander
     [not found]   ` <1297356327-sup-9107@plc.intranet.plecavalier.com>
     [not found]     ` <1297357197-sup-5893@bloovis.org>
2011-02-10 19:19       ` Philippe LeCavalier
2011-02-10 22:09         ` Philippe LeCavalier
2011-02-13  1:34           ` Moritz Wilhelmy
2011-02-13  9:51             ` Tero Tilus
2011-02-13 13:00               ` [sup-talk] How to treat List-Id headers (Was: best method for before-add-message.rb) Moritz Wilhelmy
2011-02-13 17:45               ` [sup-talk] best method for before-add-message.rb Rich Lane
2011-02-13 17:12             ` Hamish D
2011-02-13 18:08               ` Philippe LeCavalier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1297619496-sup-5791@plc.intranet.plecavalier.com \
    --to=support@plecavalier.com \
    --cc=dmishd@gmail.com \
    --cc=sup-talk@rubyforge.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox