From: Andre Tann <atann@alphasrv.net>
To: sup-talk@rubyforge.org
Subject: Re: [sup-talk] Hooks - some examples appreciated
Date: Sat, 24 Nov 2012 21:42:25 +0100 [thread overview]
Message-ID: <201211242142.25559@inter.netz> (raw)
In-Reply-To: <CA+2knqvXGPNx1wSa78RKqSTpbcgHmp-a_MGMGpjV_XOavwNFYg@mail.gmail.com>
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
prev parent reply other threads:[~2012-11-24 20:42 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-22 14:54 Andre Tann
2012-11-22 21:35 ` Jim Cheetham
2012-11-23 11:16 ` Andre Tann
2012-11-23 15:14 ` Ruthard Baudach
2012-11-23 18:49 ` Steven Hum
2012-11-23 20:20 ` Andre Tann
2012-11-25 21:09 ` Jim Cheetham
2012-11-27 12:54 ` Matthieu Rakotojaona
2012-11-27 15:13 ` Ruthard Baudach
2012-11-27 17:48 ` Matthieu Rakotojaona
2012-11-30 8:49 ` Ruthard Baudach
2012-11-24 20:42 ` Andre Tann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201211242142.25559@inter.netz \
--to=atann@alphasrv.net \
--cc=sup-talk@rubyforge.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox