Subject: Re: [sup-talk] New User Hooks Details

From: Blake Sweeney <[email-masked]>
Date: Fri, 4 Feb 2011 21:54:49 -0500

On Fri, Feb 4, 2011 at 9:15 PM, Philippe LeCavalier
<[email-masked]> 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
> [email-masked]
> 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
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Antono Vasiljev <[email-masked]>
Date: Fri, 04 Feb 2011 03:28:47 +0200

> wrong information into the wiki to start with :/ so sorry for the

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?

---

From: Philippe LeCavalier <[email-masked]>
Date: Fri, 04 Feb 2011 21:15:58 -0500

Hi.

---

From: Philippe LeCavalier <[email-masked]>
Date: Thu, 03 Feb 2011 10:58:18 -0500

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.

ruby 1.8.7 (2010-08-16 patchlevel 302) [i486-linux]
sup 0.12.1

sample hook:
#Mark Lists <lists> 

contents of ~/.sup.hooks/label.lists

plecavalier@plc:~/.sup/hooks$ cat label.lists 
[email-masked]
[email-masked]
[email-masked]
[email-masked]
[email-masked]

The only thing I can think of is possibly setting the execute bit but I wanted to checking here prior.
-- 
Thanks,
Phil
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Tero Tilus <[email-masked]>
Date: Fri, 04 Feb 2011 01:01:39 +0200

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> 

Looks 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/
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Hamish D <[email-masked]>
Date: Thu, 3 Feb 2011 23:48:56 +0000

Hamish