[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sup-talk] Hooks - some examples appreciated
Hi Jim,
thanks again for your code-snippets. To feed google and for the files:
Here is a complete example how to label incoming mail:
===snip
$ cat ~/.sup/hooks/before-add-message.rb
def tagit(message,labels)
actions=[]
labels.split(' ').each {|l|
# Check the first character of each label.
# If it starts with -, remove the label
# otherwise add it.
minus=l.match('^-(.*)$')
if minus
message.remove_label minus[1]
actions << "Del #{minus[1]}"
else
message.add_label l
actions << "Add #{l}"
end
}
log "Tagit: #{labels} -> #{message.id} : #{actions.join(',')}"
end
# Build up an array of recipients for this message
recipients=[]
message.recipients.each {|rp| recipients << rp.email }
recips = recipients.join(' ')
# Nest a set of mutually exclusive cases …
case
# Label test messages
when (message.subj =~ /test/ ) :
tagit(message,"Testlabel")
end
===snip
Still, I have no idea on how to deal with accounts. But that goes into
another thread ;)
Greetings,
--
Andre Tann
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk