Skip to content

Instantly share code, notes, and snippets.

@lilyball
Created March 27, 2014 17:27
Show Gist options
  • Save lilyball/9813145 to your computer and use it in GitHub Desktop.
Save lilyball/9813145 to your computer and use it in GitHub Desktop.
require ["envelope", "imapflags", "fileinto", "reject", "notify", "vacation", "regex", "relational", "comparator-i;ascii-numeric", "body", "copy"];
# Spam processing
if not header :contains ["X-Spam-known-sender"] "yes" {
if allof (
header :contains ["X-Backscatter"] "yes",
not header :matches ["X-LinkName"] "*"
) {
discard;
stop;
}
if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["10"] {
discard;
stop;
}
if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["4"] {
fileinto "INBOX.Junk Mail";
stop;
}
if header :is ["X-Spam-charsets"] "from='koi8-r', subject='koi8-r', plain='koi8-r'" {
fileinto "INBOX.Junk Mail";
stop;
}
}
if header :contains ["list-id", "list-post"] "<macbeta.list.valvesoftware.com>" {
fileinto "INBOX.Mailing Lists.Steam Beta";
} elsif header :contains ["list-id", "list-post"] "fish-users.lists.sourceforge.net" {
fileinto "INBOX.Mailing Lists.Fish users";
} elsif header :contains ["list-id", "list-post"] "<rust-dev.mozilla.org>" {
fileinto "INBOX.Mailing Lists.rust-dev";
} elsif header :contains ["list-id", "list-post"] "<rust.mozilla.github.com>" {
# process different notification emails differently
# Message-IDs:
# PR: <mozilla/rust/pull/11967@github.com>
# PR comment: <mozilla/rust/pull/11967/r9364118@github.com>
# Commit comment: <mozilla/rust/commit/a8a4de50592d97f576064948751b41a5e75092fa/5245928@github.com>
# Issue comment: <mozilla/rust/issues/9575/33858796@github.com>
#
# Comments on issues I'm participating in have X-GitHub-Reason that includes the reason
# that I'm participating (author, comment, mention).
if allof (
header :is ["From"] "bors <notifications@github.com>",
not header :is ["X-GitHub-Reason"] "author"
) {
# discard activity by bors
discard;
} elsif exists ["X-GitHub-Reason"] {
# keep messages for PRs I'm participating in
keep;
} elsif header :regex ["Message-ID"] "<mozilla/rust/pull/[[:digit:]]+@github\.com>" {
# keep all PRs
keep;
} else {
fileinto "INBOX.Mailing Lists.rust-github";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment