summaryrefslogtreecommitdiff
path: root/.config/maildirproc/purdue.rc
diff options
context:
space:
mode:
Diffstat (limited to '.config/maildirproc/purdue.rc')
-rw-r--r--.config/maildirproc/purdue.rc84
1 files changed, 84 insertions, 0 deletions
diff --git a/.config/maildirproc/purdue.rc b/.config/maildirproc/purdue.rc
new file mode 100644
index 0000000..9a759f5
--- /dev/null
+++ b/.config/maildirproc/purdue.rc
@@ -0,0 +1,84 @@
+# -*- 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 piazza_topic(mail, topic):
+ return (
+ is_to_or_from(mail, topic+" on Piazza")
+ or mail["Subject"].contains(topic+" on Piazza"))
+
+def my_filters(mail):
+ # Generic stuff ########################################################
+
+ if mail["Subject"].contains("[PASE]"):
+ mail.move("INBOX.PASE")
+ return
+
+ if mail["Subject"].contains("[PLUG]"):
+ mail.move("INBOX.PLUG")
+ return
+
+ if is_to_or_from(mail,"linkedin.com"):
+ mail.move("INBOX.LinkedIn")
+ return
+
+ if (
+ False
+ or mail["Subject"].contains("[CS Opportunity Update]")
+ or mail["Subject"].contains("[CS Majors]")
+ ):
+ mail.move("INBOX.CS")
+ return
+
+ # Fall 2012 ############################################################
+
+ if mail["Subject"].contains("Fall-2012-SCI-21000-001:"):
+ mail.move("INBOX.classes.2012-2.SCI210")
+ if mail["Subject"].contains("fall-2012-cs-18000"):
+ mail.move("INBOX.classes.2012-2.CS180")
+ return
+ if piazza_topic(mail, "CS 18000"):
+ mail.move("INBOX.classes.2012-2.CS180.Piazza")
+ return
+ if mail["Subject"].contains("Fall-2012-SOC-10000"):
+ mail.move("INBOX.classes.2012-2.SOC100")
+ return
+
+ # Spring 2013 ##########################################################
+
+ if mail["Subject"].contains("[CS240]") or mail["Subject"].contains("Spring-2013-CS-24000"):
+ mail.move("INBOX.classes.2013-1.CS240")
+ return
+ if piazza_topic(mail, "CS 240"):
+ mail.move("INBOX.classes.2013-1.CS240.Piazza")
+ return
+
+ if mail["Subject"].contains("Spring-2013-CS-18200"):
+ mail.move("INBOX.classes.2013-1.CS182")
+ return
+
+handle_mapping = {
+ "INBOX": my_filters,
+ }
+processor.maildirs = handle_mapping.keys()
+for mail in processor:
+ handle_mapping[mail.maildir](mail)