Howdy folks,

Normally, spam is automatically put into my imap Spam folder, but
something gets through, then I move it to the Mistakes folder, and send
it back to the imap server. Anything put in the Mistakes folder gets
processed for Spam/Ham scenarios (conversely, if I move something from
the Spam folder that is actually not spam and put it in the Mistakes
folder, then spamassassin trains bayes to learn that is actually Ham,
not Spam). This is a pretty common Bayes training
setup. 

Sadly, this is something that Sup doesn't do, so I am stuck getting all
of this spam in my inbox. so I think what I need to do is use the
mark-as-spam hook to copy the message to another location. I'm using
offlineimap, so I can just do a file copy of the actual file to the
right spot and let sup do the rest. This seems like the most logical
place to look, use this hook to make a copy of the mail to my Mistakes
maildir folder when I press 'S', and then the offlineimap process will
go and put it back on the IMAP server for processing.

It seems like a hook could do this fairly easily, but because I dont
know ruby its a lot harder for me, also I couldn't find much information
about how to use hooks. I read the hooks.txt file in the debian package,
but it wans't so useful.

Spent some time today trying to figure out how hooks work. Couldn't find
much information out there, but eventually figured out that there are a
handful of hooks available, which you can list via 'sup -l', for
example:

mark-as-spam
------------
File: /home/micah/.sup/hooks/mark-as-spam.rb
This hook is run when a thread is marked as spam
Variables: thread: The message thread being marked as spam.

basically what this means is that if you put a file in
.sup/hooks/mark-as-spam.rb with ruby code it will be executed when you
hit the S key, and the "thread" variable is available to this hook.

The above took me quite some time to determine, not being a ruby person
and all, now that I got that, I want to use it!

So what is that thread variable? I only really found it in thread.rb, so
I looked at that for a while, I find that a thread is a bunch of
messages, so I figure I need to enumerate the array. Then I taught
myself some ruby looping and variable interpolation, and came up with
this:

log "Marking thread #{thread.to_s} of size #{thread.size} as spam..."
thread.each { |message| system 'cp', message, 
'/home/me/Maildir/Personal/INBOX.Mistakes/cur' }

and hey, it almost works, just incorrectly, my sup log gets:

hook[mark-as-spam]: Marking thread <thread containing: 
<20091110072526.52367494...@waldenburg.org>> of size 1 as spam...

But... I dont know how to get the thread array to tell me where the
actual file is. I spent some more quality time with the source, and I am
pretty sure that a @thread is an array of Containers which contain the
different Messages, which are accessed via Store... but i dont know if I
can access any of that, there is a Thread class, Container class,
Message class and finally a Source class, and I think the problem is
that thread.each isn't an actual file its more of a thread object of
some sort, and if I knew how to get at the actual file, I could just
use a simple system call to copy it where I need to.

There has to be some way to have sup actually move a message, isn't
there?

thanks for any help!
micah

_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk

Reply via email to