I''m having a hard time using the hooks system.
I''m trying to add the ''AutoAddLabelsToNewMessages''.
I''ve followed the wiki and created
''~/.sup/hooks/before-add-message.rb'' with a few hooks but sup
isn''t calling them before polling.
One bit of info that seems odd to me is when I issue ''sup -l''
the hooks listed are nowhere to be found in the hooks folder yet they appear to
be working. Is that normal?
ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
sup 0.12.1
sample hook:
#Mark Lists <lists>
addressfile =
File.open("/home/plecavalier/.sup/hooks/label.lists","r")
if ! addressfile.grep(/#{message.list_address}/).empty?
message.add_label :lists
end
contents of ~/.sup.hooks/label.lists
plecavalier at plc:~/.sup/hooks$ cat label.lists
cups at easysw.com
samba at lists.samba.org
rsync at lists.samba.org
offlineimap-project at lists.alioth.debian.org
bind-users at lists.isc.org
The only thing I can think of is possibly setting the execute bit but I wanted
to checking here prior.
--
Thanks,
Phil
Philippe LeCavalier, 2011-02-03 17:58:> One bit of info that seems odd to me is when I issue ''sup -l'' the > hooks listed are nowhere to be found in the hooks folder yet they > appear to be working. Is that normal?The `sup -l` lists all the hooks sup looks for upon start. If a hook file exists, sup loads it and calls the ruby code in the file the way documented in `sup -l`.> # Mark Lists <lists> > addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r") > if ! addressfile.grep(/#{message.list_address}/).empty? > message.add_label :lists > endLooks sound on the surface. This is your ~/.sup/hooks/before-add-message.rb? New mails coming from mailinglists listed in label.lists don''t get lists-tag? You could add some logging and see whats going on. debug "before-add-message" File.open("/home/plecavalier/.sup/hooks/label.lists") do |addressfile| unless addressfile.grep(/#{message.list_address}/).empty? debug "list message #{message.id.inspect}" message.add_label :lists else debug "non-list message #{message.id.inspect}" end end Then $ SUP_LOG_LEVEL=debug sup and wait for incoming mail or temporarily use another SUP_BASE (than $HOME/.sup) with a sources.yaml pointing to a test corpus of mails. Debug output goes to log buffer. -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
> One bit of info that seems odd to me is when I issue ''sup -l'' the hooks listed are nowhere to be found in the hooks folder yet they appear to be working. Is that normal?sup -l will list the hooks you can use - it doesn''t check what hooks you''ve actually created.> sample hook: > #Mark Lists <lists> > addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r") > if ! addressfile.grep(/#{message.list_address}/).empty? > message.add_label :lists > endYou can stick debug statements in - say: debug "list address is #{message.list_address.inspect}, type is #{message.list_address.class.to_s}" and then see it in the log (while using sup, press ";" and scroll down to the log buffer). I think that message.list_address is actually of class Person, so you would want to use message.list_address.email for your case. I''ve updated the wiki to correct that - I think I may have written the wrong information into the wiki to start with :/ so sorry for the mistake. Hamish
On Thu, 2011-02-03 at 23:48 +0000, Hamish D wrote:> debug "list address is #{message.list_address.inspect}, type is > #{message.list_address.class.to_s}" > > and then see it in the log (while using sup, press ";" and scroll down > to the log buffer). > > I think that message.list_address is actually of class Person, so you > would want to use message.list_address.email for your case. I''ve > updated the wiki to correct that - I think I may have written the > wrong information into the wiki to start with :/ so sorry for the > mistake.Oh. Spent some hours debugging this issue. And list_address.to_s gives list address so it was kinda magic that list != list :) -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing?
Hi. Excerpts from Hamish D''s message of Thu Feb 03 18:48:56 -0500 2011:> > One bit of info that seems odd to me is when I issue ''sup -l'' the hooks listed are nowhere to be found in the hooks folder yet they appear to be working. Is that normal? > > sup -l will list the hooks you can use - it doesn''t check what hooks > you''ve actually created. > > > sample hook: > > #Mark Lists <lists> > > addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r") > > if ! addressfile.grep(/#{message.list_address}/).empty? > > message.add_label :lists > > end > > You can stick debug statements in - say: > > debug "list address is #{message.list_address.inspect}, type is > #{message.list_address.class.to_s}" > > and then see it in the log (while using sup, press ";" and scroll down > to the log buffer). > > I think that message.list_address is actually of class Person, so you > would want to use message.list_address.email for your case. I''ve > updated the wiki to correct that - I think I may have written the > wrong information into the wiki to start with :/ so sorry for the > mistake.Thanks for this. And thanks to everyone else who posted suggestions. Suffice it to say, I would have never figured that out on my own. I''m also seeing allot more info now with debugs here there and everywhere and can work from that. One question came to mind while I was fixing my hooks...Does the email address have to be complete or can it be just the domain? (I''m referring to the email address list in the referenced file of course) -- Thanks, Phil
On Fri, Feb 4, 2011 at 9:15 PM, Philippe LeCavalier <support at plecavalier.com> wrote:> Hi. > > Excerpts from Hamish D''s message of Thu Feb 03 18:48:56 -0500 2011: >> > One bit of info that seems odd to me is when I issue ''sup -l'' the hooks listed are nowhere to be found in the hooks folder yet they appear to be working. Is that normal? >> >> sup -l will list the hooks you can use - it doesn''t check what hooks >> you''ve actually created. >> >> > sample hook: >> > #Mark Lists <lists> >> > addressfile = File.open("/home/plecavalier/.sup/hooks/label.lists","r") >> > if ! addressfile.grep(/#{message.list_address}/).empty? >> > message.add_label :lists >> > end >> >> You can stick debug statements in - say: >> >> debug "list address is #{message.list_address.inspect}, type is >> #{message.list_address.class.to_s}" >> >> and then see it in the log (while using sup, press ";" and scroll down >> to the log buffer). >> >> I think that message.list_address is actually of class Person, so you >> would want to use message.list_address.email for your case. I''ve >> updated the wiki to correct that - I think I may have written the >> wrong information into the wiki to start with :/ so sorry for the >> mistake. > Thanks for this. And thanks to everyone else who posted suggestions. Suffice it to say, I would have never figured that out on my own. > > I''m also seeing allot more info now with debugs here there and everywhere and can work from that. > > One question came to mind while I was fixing my hooks...Does the email address have to be complete or can it be just the domain? (I''m referring to the email address list in the referenced file of course) > > -- > Thanks, > Phil > _______________________________________________ > sup-talk mailing list > sup-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/sup-talk >I''m a bit biased but I think my gem sup_tag could help out. It makes tagging messages pretty easy. For example: tag do list_address /sup-talk/, :sup end tags all messages with sup-talk in the list address as sup. Checkout out: https://github.com/blakesweeney/sup_tag Blake