* [sup-talk] best method for before-add-message.rb @ 2011-02-10 14:44 Philippe LeCavalier 2011-02-10 16:40 ` Mark Alexander 0 siblings, 1 reply; 10+ messages in thread From: Philippe LeCavalier @ 2011-02-10 14:44 UTC (permalink / raw) To: sup-talk Hi All. I'm still working on my initial labeling/hooks and best choices thereof. I'm torn between a few options. i)external file reference (would be my preferred method) -can't list anything other than full email addresses in the file @domain.com, wildcards...etc. would be nice -can't comment in the file. It would be nice to weed out comments -is it possible that when an address has a subdomain the example in the wiki breaks? ie list@list.domain.com none of my hooks for these types of addresses seem to work -is Sup caching the referenced file? if not, I presume this option significantly slows things down ii)not using an external file makes the hook file lengthy. However it seems to be the only safe way of adding multiple labels - which I feel crucial to making a strong searchable system. Perhaps a label(s)-markread-archive would be nice :) -using this method I find myself writing a ton of rules for the same thread. a)label the thread from a particular community/client/area b)label the thread from a particular person within said community/clientel/area c)label it something useful ie (not)important/archive/redirect/bounce(hehe)...etc. I'm assuming my difficulties spring from a few basic assumptions; I can't write any code let alone Ruby, if my life depended on it. The wiki has solid working examples for those who can work with Ruby. Again I don't speak Ruby. And mostly, I come form a world where things get filtered to folders :-( I'm really trying to keep an open mind and I know I'll get there but my inbox now has thousands of mails in it and I'm the type that kept a strict 0 count. In order for me to move to Sup I had to get *real* disorganized before getting *real* organized ;-) All that to say that for types like me, it's all about copying other, less ruby-challenged, peoples work. So for the past three weeks I've been living in the wiki....It's a pretty lonely place out there! In keeping an open mind about all this, I'm open to hearing examples of how others handle there workflow that are achieving the same goal I have in mind. ie label everything with individual labels and archive it all using the least/simplest/most efficient code possible. This way I can search for clients,client A,reports,after:tue-jan-18(I think the latter is prob. wrong but feel like looking up chronic's standards at the moment:-) ) My mail is really important to me so if the only response I get from this is "learn Ruby you lazy-ass-bastard!" I'll get the message(lousy pun eh?) ;-) -- Thanks, Phil _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 2011-02-10 14:44 [sup-talk] best method for before-add-message.rb Philippe LeCavalier @ 2011-02-10 16:40 ` Mark Alexander [not found] ` <1297356327-sup-9107@plc.intranet.plecavalier.com> 0 siblings, 1 reply; 10+ messages in thread From: Mark Alexander @ 2011-02-10 16:40 UTC (permalink / raw) To: Philippe LeCavalier; +Cc: sup-talk Excerpts from Philippe LeCavalier's message of Thu Feb 10 09:44:18 -0500 2011: > i)external file reference (would be my preferred method) > -can't list anything other than full email addresses in the file > @domain.com, wildcards...etc. would be nice I'm not sure if this will help (it's pretty primitive), but here's my before-add-message.rb, showing how to do regular expression matches on addresses: # Label by subject. This is useful for messages # generated automatically by Bugzilla or cron jobs. case message.subj when /\[P4 SUBMIT/ message.add_label :p4 when /\[Bug.*project:/ message.add_label :projbugs when /\[Bug/ message.add_label :bugs when /project.*suite results/ message.add_label :testing end # Label by recipients. This is useful for mailing lists. to_string = message.recipients.map { |t| t.email }.join(" ") case to_string # Personal labels when /\bsup-(devel|talk)@rubyforge.org\b/ message.add_label :sup # Work labels when /pi@widgets/ message.add_label :pi when /git-users@widgets/ message.add_label :git when /team-project@widgets/ message.add_label :project end # Label by from. This is useful for personal emails. case message.from.email when /@amazon/ message.add_label :amazon when /@facebook/ message.add_label :facebook when /@netflix/ message.add_label :netflix when /somebody@gmail.com|somebody@aol.com/ message.add_label :somebody end _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <1297356327-sup-9107@plc.intranet.plecavalier.com>]
[parent not found: <1297357197-sup-5893@bloovis.org>]
* Re: [sup-talk] best method for before-add-message.rb [not found] ` <1297357197-sup-5893@bloovis.org> @ 2011-02-10 19:19 ` Philippe LeCavalier 2011-02-10 22:09 ` Philippe LeCavalier 0 siblings, 1 reply; 10+ messages in thread From: Philippe LeCavalier @ 2011-02-10 19:19 UTC (permalink / raw) To: Mark Alexander; +Cc: sup-talk Hi. I apologize in advance for the broken thread...Since I forgot a linebreak at the beginning of the body so everything got mangled upon exiting vim. I did my best to re-create the order. Excerpts from Mark Alexander's message of Thu Feb 10 12:00:17 -0500 2011: > Excerpts from Philippe LeCavalier's message of Thu Feb 10 11:52:53 -0500 2011: > > Hi Mark. > > Have you tried? > > > > case message.subj > > when /\[P4 SUBMIT/ > > message.add_label :p4 > > message.remove_label :inbox > > end > > No, I haven't tried remove_label. I did some testing and for some reason I cannot see, the above code automatically archives the msg without any obvious code telling sup to do so. If I: case message.from.email when /@plecavalier.com/ message.add_label :TEST message.add_label :TEST2 message.add_label :TEST3 end tests sent to myself are respectively labeled TEST TEST2 TEST3 but are also striped of the inbox label. Since this is exactly what I want this works for me but... -- Thanks, Phil _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 2011-02-10 19:19 ` Philippe LeCavalier @ 2011-02-10 22:09 ` Philippe LeCavalier 2011-02-13 1:34 ` Moritz Wilhelmy 0 siblings, 1 reply; 10+ messages in thread From: Philippe LeCavalier @ 2011-02-10 22:09 UTC (permalink / raw) To: Philippe LeCavalier; +Cc: sup-talk Hi All. Excerpts from Philippe LeCavalier's message of Thu Feb 10 14:19:49 -0500 2011: > Hi. I apologize in advance for the broken thread...Since I forgot a linebreak at the beginning of the body so everything got mangled upon exiting vim. I did my best to re-create the order. > > > Excerpts from Mark Alexander's message of Thu Feb 10 12:00:17 -0500 2011: > > > Excerpts from Philippe LeCavalier's message of Thu Feb 10 11:52:53 -0500 2011: > > > > Hi Mark. > > > Have you tried? > > > > > case message.subj > > > when /\[P4 SUBMIT/ > > > message.add_label :p4 > > > message.remove_label :inbox > > > end > > > No, I haven't tried remove_label. > > I did some testing and for some reason I cannot see, the above code automatically archives the msg without any obvious code telling sup to do so. > > If I: > > case message.from.email > when /@plecavalier.com/ > message.add_label :TEST > message.add_label :TEST2 > message.add_label :TEST3 > end > > tests sent to myself are respectively labeled TEST TEST2 TEST3 but are also striped of the inbox label. Since this is exactly what I want this works for me but... Well, I don't know if this was the most efficient method but I took Mark's example and ran with it. This method accomplishes my goal to add(and remove!) multiple labels in one swish and is legible enough for the simple-minded like myself. Note: the above statement re. removing the inbox label without having specifying it explicitely is false...No idea why Sup was doing that but restarting sup completely, fixed that oddity. Perhaps my understanding of 'H' is incorrect!? Thanks a bunch Mark my inbox is well on it's way to 0 as it once was. -- Thanks, Phil _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 2011-02-10 22:09 ` Philippe LeCavalier @ 2011-02-13 1:34 ` Moritz Wilhelmy 2011-02-13 9:51 ` Tero Tilus 2011-02-13 17:12 ` Hamish D 0 siblings, 2 replies; 10+ messages in thread From: Moritz Wilhelmy @ 2011-02-13 1:34 UTC (permalink / raw) To: sup-talk Hi, 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 way around this? Right now I'm doing something along the lines of this: # Mailing lists lids_re = { /<foo\.lists\.foo\.com>/ => "foo", /<dev\.something\.org>/ => ["something", "devel"] } def add_labels message, labels labels.each do |l| message.add_label l end end if message.raw_header =~ /^List-I[dD]: ([^\n]+)/ #log "List ID: #{$1}" message.add_label "list" lids_re.keys.each do |re| add_labels message lids_re[re] if $1 =~ re end end Can I pull arbitrary, parsed headers directly out of the message object, or do I have to do my own parsing? Best regards, Moritz _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 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 1 sibling, 2 replies; 10+ messages in thread From: Tero Tilus @ 2011-02-13 9:51 UTC (permalink / raw) To: Sup users Moritz Wilhelmy, 2011-02-13 03:34: > what would be the best way to match - for instance - the > List-Id-Header in case it's present? List-Id is a whole separate kind of beast. My stragy dealing with it looks like this. Comments in finnish. Go google translate. ;) == clip from ~/.sup/hooks/before-add-message.rb == hdr = message.raw_header # Yritetään hakea listalle label List-Id headerista ja jos sellaista # ei ole (mm. pipermail-arkistot) niin otsikkoriviltä [listanimestä]. # Listaheadereita on montaa sorttia # # List-Id: effi-alert.winston.effi.org # List-Id: <effipalvelin.winston.effi.org> # List-Id: EFFIn hallituksen keskusteluja <board.effi.org> # List-Id: =?iso-8859-1?q?Keski-Suomen_EFFIl=E4iset?= <ks-effi.lists.jyu.fi> # List-Id: "Hear ry:n julkinen tiedotuslista: Radio Hear, Linnunlaulupubi, # List-Id: =?iso-8859-1?q?El=E4m=E4_on_peli=E4=2C_j=E4rjest=E4j=E4lista?= if m = (hdr.match(/^List-Id: +[^<]*<([^>\s]+)> *$/i) or # tyyppi 1 hdr.match(/^List-Id: +([^<>=\s]+) *$/i) or # tyypit 2-4 hdr.match(/^Subject: +\[ *([^\] ]+) *\]/i)) list_id = m[1] list_id = 'effi-hallitus' if list_id == 'board.effi.org' list_id = 'effi-asiantuntijat' if list_id == 'asiantuntijat.effi.org' list_id = 'maahinkainen-jasenet' if list_id == 'jasenet.maahinkainen.org' list_id = 'lev' if list_id == 'lev-list' list_id = list_id.split('.', 2)[0].downcase message.add_label list_id end == clip end == > Can I pull arbitrary, parsed headers directly out of the message > object, or do I have to do my own parsing? Uh, oh. Looks like no, but it is pretty close, berause Message#parse_header already builds parsed hash of arbitrary headers internally. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/ _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] How to treat List-Id headers (Was: best method for before-add-message.rb) 2011-02-13 9:51 ` Tero Tilus @ 2011-02-13 13:00 ` Moritz Wilhelmy 2011-02-13 17:45 ` [sup-talk] best method for before-add-message.rb Rich Lane 1 sibling, 0 replies; 10+ messages in thread From: Moritz Wilhelmy @ 2011-02-13 13:00 UTC (permalink / raw) To: sup-talk Hello, Excerpts from Tero Tilus's message of Sun Feb 13 10:51:02 +0100 2011: > > what would be the best way to match - for instance - the > > List-Id-Header in case it's present? > List-Id is a whole separate kind of beast. My stragy dealing with it > looks like this. Comments in finnish. Go google translate. ;) Ah, well, the problem I have is something like this List-Id: "very long descriptive text on what the list is about" <list.lists.something.com> Because the actual List-Id is so long, it's sometimes wrapped into the next line per convention (i.e. when the descriptive text is already very long and the line needs to be wrapped because the actual List-Id would exceed the character limit per line, I think it's around 80 characters). Thus, my regexes don't match in all cases. I want to match the list by the part between the <>, not the descriptive text, which is a bit problematic because of the line-wrapping. However, if I could get the full List-Id line from the parsed headers hashtable, this would eliminate my parsing problems. > > Can I pull arbitrary, parsed headers directly out of the message > > object, or do I have to do my own parsing? > Uh, oh. Looks like no, but it is pretty close, berause > Message#parse_header already builds parsed hash of arbitrary headers > internally. Well, making this publicly accessible to the before-add-message hook would simplify a lot of the stuff I do with my email in order to place the right labels. So maybe, this is a feature request to the sup developers, but maybe I also got everything wrong. ;) Cheers, Moritz _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 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 ` Rich Lane 1 sibling, 0 replies; 10+ messages in thread From: Rich Lane @ 2011-02-13 17:45 UTC (permalink / raw) To: Tero Tilus; +Cc: Sup users Excerpts from Tero Tilus's message of 2011-02-13 04:51:02 -0500: > Moritz Wilhelmy, 2011-02-13 03:34: > > Can I pull arbitrary, parsed headers directly out of the message > > object, or do I have to do my own parsing? > > Uh, oh. Looks like no, but it is pretty close, berause > Message#parse_header already builds parsed hash of arbitrary headers > internally. > I use "hs = message.source.load_header(message.source_info)", which we should probably make a convenience method on Message. _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 2011-02-13 1:34 ` Moritz Wilhelmy 2011-02-13 9:51 ` Tero Tilus @ 2011-02-13 17:12 ` Hamish D 2011-02-13 18:08 ` Philippe LeCavalier 1 sibling, 1 reply; 10+ messages in thread From: Hamish D @ 2011-02-13 17:12 UTC (permalink / raw) To: sup-talk > 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 _______________________________________________ sup-talk mailing list sup-talk@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-talk ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [sup-talk] best method for before-add-message.rb 2011-02-13 17:12 ` Hamish D @ 2011-02-13 18:08 ` Philippe LeCavalier 0 siblings, 0 replies; 10+ messages in thread From: Philippe LeCavalier @ 2011-02-13 18:08 UTC (permalink / raw) To: Hamish D; +Cc: sup-talk 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-02-13 18:49 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-02-10 14:44 [sup-talk] best method for before-add-message.rb 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 is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox