diff options
Diffstat (limited to '.maildirproc/purdue.rc')
-rw-r--r-- | .maildirproc/purdue.rc | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/.maildirproc/purdue.rc b/.maildirproc/purdue.rc new file mode 100644 index 0000000..546b792 --- /dev/null +++ b/.maildirproc/purdue.rc @@ -0,0 +1,82 @@ +# -*- mode: python; -*- + +import subprocess + +processor.maildir_base = "~/Maildir.purdue" +processor.auto_reload_rcfile = True + +def is_to_or_from(mail,address): + """ + Return true if [mail] is to or from an address that contains [address]. + """ + return ( + mail["From"].contains(address) + or mail.target.contains(address)) +def is_to_or_from_re(mail,address): + """ + Return true if [mail] is to or from an address that matches the + regex [address]. + """ + return ( + mail["From"].matches(address) + or mail.target.matches(address)) + +def handle_incoming_ham(mail): + my_filters(mail) + +def handle_incoming_unknown(mail): + # Filter spam + + spam = bogofilter_auto(mail) + if spam == 0: + handle_incoming_spam(mail) + return + elif spam == 1: + handle_incoming_ham(mail) + return + elif spam == 2: + # maybe spam + return + else: + mail.move(".Error") + return + +def my_filters(mail): + if mail["Subject"].contains("[PASE]"): + mail.move("INBOX.PASE") + return + if mail["Subject"].contains("[PLUG]"): + mail.move("INBOX.PLUG") + return + if mail["Subject"].contains("Fall-2012-SCI-21000-001:"): + mail.move("INBOX.classes.SCI210") + if ( + False + or mail["Subject"].contains("[CS Opportunity Update]") + or mail["Subject"].contains("[CS Majors]") + ): + mail.move("INBOX.CS") + return + if is_to_or_from(mail,"linkedin.com"): + mail.move("INBOX.LinkedIn") + return + if mail["Subject"].contains("fall-2012-cs-18000"): + mail.move("INBOX.classes.CS180") + return + if ( + False + or is_to_or_from(mail,"CS 18000 on Piazza") + or mail["Subject"].contains("CS 18000 on Piazza") + ): + mail.move("INBOX.classes.CS180.Piazza") + return + if mail["Subject"].contains("Fall-2012-SOC-10000"): + mail.move("INBOX.classes.SOC100") + return + +handle_mapping = { + "INBOX": handle_incoming_ham, + } +processor.maildirs = handle_mapping.keys() +for mail in processor: + handle_mapping[mail.maildir](mail) |