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