From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.42.240.136 with SMTP id la8cs241191icb; Sun, 13 Feb 2011 10:23:05 -0800 (PST) Received: by 10.229.189.20 with SMTP id dc20mr2116339qcb.231.1297621385369; Sun, 13 Feb 2011 10:23:05 -0800 (PST) Return-Path: Received: from rubyforge.org (rubyforge.org [205.234.109.19]) by mx.google.com with ESMTP id m11si3235437qcu.13.2011.02.13.10.23.04; Sun, 13 Feb 2011 10:23:04 -0800 (PST) Received-SPF: pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) client-ip=205.234.109.19; Authentication-Results: mx.google.com; spf=pass (google.com: domain of sup-talk-bounces@rubyforge.org designates 205.234.109.19 as permitted sender) smtp.mail=sup-talk-bounces@rubyforge.org Received: from rubyforge.org (rubyforge.org [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id D93BC19782DB; Sun, 13 Feb 2011 13:23:03 -0500 (EST) Received: from plecavalier.com (plecavalier.com [64.40.149.83]) by rubyforge.org (Postfix) with ESMTP id 35C361858112 for ; Sun, 13 Feb 2011 13:08:27 -0500 (EST) Received: (qmail 9432 invoked from network); 13 Feb 2011 12:08:26 -0600 Received: from xplr-142-46-160-183.xplornet.com (HELO localhost) (142.46.160.183) by thelittlecloset.ca with (DHE-RSA-AES128-SHA encrypted) SMTP; 13 Feb 2011 12:08:25 -0600 From: Philippe LeCavalier To: Hamish D In-reply-to: References: <1297346751-sup-70@plc.intranet.plecavalier.com> <1297355619-sup-8657@bloovis.org> <1297356327-sup-9107@plc.intranet.plecavalier.com> <1297357197-sup-5893@bloovis.org> <1297364797-sup-8388@plc.intranet.plecavalier.com> <1297375381-sup-2823@plc.intranet.plecavalier.com> <1297560324-sup-4333@niflheimr> Date: Sun, 13 Feb 2011 13:08:23 -0500 Message-Id: <1297619496-sup-5791@plc.intranet.plecavalier.com> User-Agent: Sup/0.12.1 Cc: sup-talk Subject: Re: [sup-talk] best method for before-add-message.rb X-BeenThere: sup-talk@rubyforge.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: User & developer discussion of Sup List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: sup-talk-bounces@rubyforge.org Errors-To: sup-talk-bounces@rubyforge.org 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