summaryrefslogtreecommitdiff
path: root/.config/maildirproc/att.rc
diff options
context:
space:
mode:
Diffstat (limited to '.config/maildirproc/att.rc')
-rw-r--r--.config/maildirproc/att.rc201
1 files changed, 105 insertions, 96 deletions
diff --git a/.config/maildirproc/att.rc b/.config/maildirproc/att.rc
index 0252c74..6b31260 100644
--- a/.config/maildirproc/att.rc
+++ b/.config/maildirproc/att.rc
@@ -1,7 +1,9 @@
# -*- mode: python; indent-tabs-mode: t -*-
import os
+import os.path
import subprocess
+import datetime
processor.maildir_base = "~/Maildir"
processor.auto_reload_rcfile = True
@@ -24,6 +26,16 @@ def is_to_or_from_re(mail,address):
return (
mail["From"].matches(address)
or mail.target.matches(address))
+def move_ham(mail,folder):
+ y = datetime.datetime.now().year
+ folder = "FOLDERS.Ham."+str(y)+folder
+ dir = processor.maildir_base+"/"+folder
+ if not os.path.isfile(dir+"/maildirfolder"):
+ os.makedirs(dir+"/tmp", 0o777, True)
+ os.makedirs(dir+"/new", 0o777, True)
+ os.makedirs(dir+"/cur", 0o777, True)
+ open(dir+"/maildirfolder", 'a').close()
+ mail.move(folder)
def bogofilter_auto(mail):
p = subprocess.Popen(
@@ -37,20 +49,17 @@ def bogofilter_auto(mail):
"Error running bogofilter: Return code = {0!r}".format(
p.returncode))
return p.returncode
-
def bogofilter_ham(mail):
subprocess.call(["bogofilter", "-S", "-n", "-I", mail.path])
-
def bogofilter_spam(mail):
subprocess.call(["bogofilter", "-N", "-s", "-I", mail.path])
-def handle_incoming_spam_training(mail):
- bogofilter_spam(mail)
- mail.move("FOLDERS.Spam")
-
def handle_incoming_ham_training(mail):
bogofilter_ham(mail)
handle_incoming_ham(mail)
+def handle_incoming_spam_training(mail):
+ bogofilter_spam(mail)
+ mail.move("FOLDERS.Spam")
def handle_incoming_ham(mail):
my_filters(mail)
@@ -60,18 +69,30 @@ def handle_incoming_spam(mail):
def handle_incoming_unknown(mail):
# Filter spam
+ # Whitelist
if (
False
- or mail["Subject"].contains("[systemd-devel]")
- or mail["Subject"].contains("[PATCH")
- or mail["Subject"].contains("[Dev]")
- or mail["Subject"].contains("[Maintenance]")
- or is_to_or_from(mail, "gnu.org")
or is_to_or_from(mail, "fsf.org")
+ or is_to_or_from(mail, "gnu.org")
+ or is_to_or_from(mail, "parabola.nu")
+ or is_to_or_from(mail, "parabolagnulinux.org")
+ or mail["From"] == "MAILER-DAEMON@yahoo.com"
+ or mail["From"].contains("@facebookmail.com>")
+ or mail["From"].contains("@gandi.net")
+ or mail["From"].contains("@goodwillindy.org>")
+ or mail["From"].contains("@lpi.org>")
+ or mail["From"].contains("@msdlt.k12.in.us>")
or mail["From"].contains("@parabola.nu")
+ or mail["From"].contains("@post.oreilly.com>")
+ or mail["From"].contains("@scouting.org>")
+ or mail["From"].contains("@wolframalpha.com>")
or mail["From"].contains("parabolagnulinux.org")
- or mail["From"].contains("@facebookmail.com>")
- or mail["List-Id"].matches(".*\.(gnu|archlinux|parabolagnulinuxlibre)\.org")
+ or mail["List-Id"].matches(".*\.(gnu|gnome|archlinux|parabolagnulinuxlibre)\.org")
+ or mail["List-Id"].matches(".*\.parabola\.nu")
+ or mail["Subject"].contains("[Dev]")
+ or mail["Subject"].contains("[Maintenance]")
+ or mail["Subject"].contains("[PATCH")
+ or mail["Subject"].contains("[systemd-devel]")
):
handle_incoming_ham_training(mail)
return
@@ -84,10 +105,10 @@ def handle_incoming_unknown(mail):
handle_incoming_ham(mail)
return
elif spam == 2:
- mail.move("Inbox")
+ mail.move("FOLDERS.MysteryMeat")
return
else:
- mail.move("FOLDERS.Error")
+ mail.move("FOLDERS.BogoFail")
return
def my_filters(mail):
@@ -98,7 +119,7 @@ def my_filters(mail):
or mail["List-Id"].matches(list+"\.gnu\.org")
or mail["Subject"].contains('['+list+']')
):
- mail.move("FOLDERS.software."+list)
+ move_ham(mail,".software."+list)
return
# Sort mail from other software mailing lists
@@ -107,67 +128,54 @@ def my_filters(mail):
or mail["List-Id"].matches("social-discuss\.gnu\.org")
or mail["Subject"].contains("social-discuss")
):
- mail.move("FOLDERS.software.social")
+ move_ham(mail,".software.social")
return
if mail["List-Id"].matches("networkmanager-list\.gnome\.org"):
- mail.move("FOLDERS.software.networkmanager")
+ move_ham(mail,".software.networkmanager")
return
- if mail["List-Id"].matches("maintenance.lists.parabolagnulinux.org"):
- if mail["From"].contains("monit@"):
- if mail["Message-Id"].contains("@repo.parabolagnulinux.org"):
- if mail["Subject"].matches("^\[Maintenance\] monit alert -- (Execution|Connection) (succeeded|failed) sshd$"):
- mail.move("FOLDERS.software.parabola-maintenance.monit-repo.sshd")
- return
- mail.move("FOLDERS.software.parabola-maintenance.monit-repo")
- return
- if mail["Message-Id"].contains("@rshg054.dnsready.net"):
- mail.move("FOLDERS.software.parabola-maintenance.monit-rshg054")
- return
- if mail["Subject"].matches("Cron <.*@repo>"):
- mail.move("FOLDERS.software.parabola-maintenance.cron-repo")
- return
- if mail["Subject"].matches("Cron <.*@rshg054>"):
- mail.move("FOLDERS.software.parabola-maintenance.cron-rshg054")
- return
- mail.move("FOLDERS.software.parabola-maintenance")
+ if mail["List-Id"].matches("maintenance\.lists\.parabola(gnulinux\.org|\.nu)"):
+ move_ham(mail,".software.parabola.maintenance")
return
- #if is_to_or_from(mail, "parabola.nu"):
- # mail.move("FOLDERS.software.parabola-labs")
- # return
+ if is_to_or_from(mail, "labs@parabola.nu"):
+ move_ham(mail,".software.parabola.labs")
+ return
if (
False
- or mail["List-Id"].matches("parabolagnulinux.org")
+ or mail["List-Id"].matches("parabolagnulinux\.org")
+ or mail["List-Id"].matches("parabola\.nu")
or is_to_or_from(mail, "parabolagnulinux.org")
or is_to_or_from(mail, "kiwwwi.com.ar")
+ or is_to_or_from(mail, "parabola.nu")
):
if mail["Subject"].contains("[Django]"):
- mail.move("FOLDERS.software.parabola-maintenance.django")
+ move_ham(mail,".software.parabola.maintenance.django")
+ return
+ else:
+ move_ham(mail,".software.parabola.dev")
return
- mail.move("FOLDERS.software.parabola-dev")
- return
if (mail["List-Id"].matches("pacman-dev.archlinux.org")):
- mail.move("FOLDERS.software.pacman-dev")
+ move_ham(mail,".software.pacman-dev")
return
if (mail["List-Id"].matches("systemd-devel.lists.freedesktop.org") or is_to_or_from(mail, "systemd-devel@lists.freedesktop.org")):
- mail.move("FOLDERS.software.systemd-devel")
+ move_ham(mail,".software.systemd-devel")
return
for subject_re in [
"\[Stow-[^\]]*\].*",
]:
if mail["Subject"].matches(subject_re):
- mail.move("FOLDERS.software")
+ move_ham(mail,".software")
return
# Sort mail from some social websites
if mail["From"].matches("facebook(|mail)\.com"):
- mail.move("FOLDERS.Social.Facebook")
+ move_ham(mail,".Social.Facebook")
return
if (
@@ -175,15 +183,24 @@ def my_filters(mail):
or mail["From"].matches("identi\.ca")
or mail["From"].matches("statusnet")
):
- mail.move("FOLDERS.Social.Identica")
+ move_ham(mail,".Social.Identica")
return
+ if (
+ False
+ or mail["From"].contains("@gandi.net")
+ or mail["From"].contains("@ramhost.us")
+ or mail["From"].contains("@startcom.org")
+ ):
+ move_ham(mail,".lukeshu-com")
+ return
+
if mail["From"].matches("twitter\.com"):
- mail.move("FOLDERS.Social.Twitter")
+ move_ham(mail,".Social.Twitter")
return
if mail["From"].matches("@xkcd\.com"):
- mail.move("FOLDERS.Social.xkcd")
+ move_ham(mail,".Social.xkcd")
return
# Sort mail related to Troop 276
@@ -207,30 +224,24 @@ def my_filters(mail):
or is_to_or_from(mail,"mytroop.us")
or is_to_or_from(mail,"crossroadsbsa.org")
):
- mail.move("FOLDERS.BoyScouts")
+ move_ham(mail,".BoyScouts")
return
# Sort mail from misc people
- if mail["From"].matches("margieshu@sbcglobal\.net"):
- mail.move("FOLDERS.misc.Mom")
+ if (
+ False
+ or is_to_or_from(mail,"margieshu@sbcglobal.net")
+ or is_to_or_from(mail,"3174451635@mms.att.net")
+ ):
+ move_ham(mail,".misc.Mom")
return
for address in [
- "justicejade10@aol.com",
- "parsonsjade@aol.com",
- "parsonstjade@gmail.com",
- "jadparso@umail.iu.edu",
- ]:
- if is_to_or_from(mail,address):
- mail.move("FOLDERS.misc.Jade")
- return
-
- for address in [
"nintendo.com",
"nintendo-news.com",
]:
if mail["From"].contains(address):
- mail.move("FOLDERS.misc.Nintendo")
+ move_ham(mail,".misc.Nintendo")
return
for address in [
@@ -239,7 +250,7 @@ def my_filters(mail):
"CompTIA",
]:
if mail["From"].contains(address):
- mail.move("FOLDERS.misc.CompTIA")
+ move_ham(mail,".misc.CompTIA")
return
# Sort mail from FRC people
@@ -264,37 +275,38 @@ def my_filters(mail):
"william.walk@gmail.com",
]:
if is_to_or_from(mail,address):
- mail.move("FOLDERS.School.Robotics")
+ move_ham(mail,".School.Robotics")
return
for subject_re in [
"robotics",
- "1024",
+ "\b1024\b",
+ "\b4272\b",
"kil-?a-?bytes",
]:
if mail["Subject"].matches(subject_re):
- mail.move("FOLDERS.School.Robotics")
+ move_ham(mail,".School.Robotics")
return
# Sort mail from software people
for address in [
"@archlinux.org",
+ "@canonical.org",
+ "@cnuk.org",
+ "@eff.org",
+ "@foocorp.net",
"@fsf.org",
"@github.com",
- "canonical.org",
- "cnuk.org",
- "eff.org",
- "esr@thyrsus.com",
- "foocorp.net",
- "gitorious.org",
- "gnome.org",
- "gnu.org",
- "ietf.org",
- "kde.org",
- "sourceforge.com",
+ "@gitorious.org",
+ "@gnome.org",
+ "@gnu.org",
+ "@ietf.org",
+ "@kde.org",
+ "@sourceforge.com",
+ "@thyrsus.com",
"trustees@core3.amsl.com",
]:
if is_to_or_from(mail,address):
- mail.move("FOLDERS.software")
+ move_ham(mail,".software")
return
@@ -304,16 +316,16 @@ def my_filters(mail):
or is_to_or_from(mail, "@lnnorthstar.org")
or is_to_or_from(mail, "lnnorthstar.org@tigertech.net")
):
- mail.move("FOLDERS.School.Newspaper")
+ move_ham(mail,".School.Newspaper")
return
# Sort mail from various employers/people who pay me
if is_to_or_from(mail, "@precisepath.com"):
- mail.move("FOLDERS.Work.PrecisePath")
+ move_ham(mail,".Work.PrecisePath")
return
if is_to_or_from(mail,"susyphil@aol.com"):
- mail.move("FOLDERS.Work.PMCH")
+ move_ham(mail,".Work.PMCH")
for address in [
"d.farrar@comcast.net",
@@ -321,7 +333,7 @@ def my_filters(mail):
"@vmware.com",
]:
if is_to_or_from(mail,address):
- mail.move("FOLDERS.Work.FAST")
+ move_ham(mail,".Work.FAST")
return
# Sort misc newsletters
@@ -335,7 +347,7 @@ def my_filters(mail):
or mail["From"].contains("info@demandprogress.org")
or (mail["From"].contains("@sparkfun.com") and mail["Message-Id"].contains("rsgsv.net"))
):
- mail.move("FOLDERS.misc.Newsletters")
+ move_ham(mail,".misc.Newsletters")
return
if (
@@ -351,7 +363,7 @@ def my_filters(mail):
or mail["Subject"].contains("NHS")
or mail["Subject"].contains("National Honor Society")
):
- mail.move("FOLDERS.School")
+ move_ham(mail,".School")
return
# from college stuff
@@ -360,44 +372,41 @@ def my_filters(mail):
or mail["Subject"].contains("NYLF") # National Youth Leadership Conference
or mail["Subject"].contains("NSHSS")
):
- mail.move("FOLDERS.College.Societies")
+ move_ham(mail,".College.Societies")
return
if (
False
- #or mail["From"].contains(".edu")
or mail["From"].contains("admissions@")
- #or mail["From"].contains("college")
- #or mail["From"].contains("university")
or mail["Subject"].contains("college")
# now we get to the BS
or mail["From"].contains("@dreamitdoitindiana.com")
or mail["From"].contains("@indianatechinfo.org")
):
- mail.move("FOLDERS.College")
+ move_ham(mail,".College")
return
if mail["From"].contains("@projectwonderful.com"):
- mail.move("FOLDERS.misc.ProjectWonderful")
+ move_ham(mail,".misc.ProjectWonderful")
return
if (
False
or mail["From"].matches("@localhost")
or mail["From"].matches("@[^,>]*\.local")
- or mail["From"].matches("@[^,>]*\.lukeshu\.ath\.cx")
+ or mail["From"].matches("@[^,>]*\.lan")
or mail["To"].matches("luke@")
):
- mail.move("FOLDERS.LocalSystems")
+ move_ham(mail,".LocalSystems")
return
if (
False
or mail["Subject"].contains("password")
or mail["Subject"].contains("account")
):
- mail.move("FOLDERS.misc.accounts")
+ move_ham(mail,".misc.accounts")
return
- mail.move("FOLDERS.Ham")
+ move_ham(mail,"")
handle_mapping = {
"Inbox": handle_incoming_unknown,