Advertisement
Guest User

Untitled

a guest
Dec 4th, 2015
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.16 KB | None | 0 0
  1. require ["envelope", "imapflags", "fileinto", "reject", "notify", "vacation", "regex", "relational", "comparator-i;ascii-numeric", "body", "copy"];
  2.  
  3. # Spam processing
  4. if not header :contains ["X-Spam-known-sender"] "yes" {
  5. if allof (
  6. header :contains ["X-Backscatter"] "yes",
  7. not header :matches ["X-LinkName"] "*"
  8. ) {
  9. discard;
  10. stop;
  11. }
  12. if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["8"] {
  13. discard;
  14. stop;
  15. }
  16. if header :value "ge" :comparator "i;ascii-numeric" ["X-Spam-score"] ["4"] {
  17. fileinto "INBOX.Junk Mail";
  18. stop;
  19. }
  20. if header :is ["X-Spam-charsets"] "from='koi8-r', subject='koi8-r', plain='koi8-r'" {
  21. fileinto "INBOX.Junk Mail";
  22. stop;
  23. }
  24. }
  25.  
  26. # Mailing Lists
  27. if header :contains ["List-ID", "List-Post"] "[redacted]" {
  28. fileinto "INBOX.Mailing Lists.[redacted]";
  29. stop;
  30. }
  31. if header :contains ["List-ID", "List-Post"] "[redacted]" {
  32. fileinto "INBOX.Mailing Lists.[redacted]";
  33. stop;
  34. }
  35. if header :contains ["List-ID", "List-Post"] "<rust-dev.mozilla.org>" {
  36. fileinto "INBOX.Mailing Lists.rust-dev";
  37. stop;
  38. }
  39. if header :contains "List-ID" "<swift-evolution.swift.org>" {
  40. fileinto "INBOX.Swift.swift-evolution";
  41. stop;
  42. }
  43. if header :contains "List-ID" "<swift-users.swift.org>" {
  44. fileinto "INBOX.Swift.swift-users";
  45. stop;
  46. }
  47. if header :contains "List-ID" "<swift-corelibs-dev.swift.org>" {
  48. fileinto "INBOX.Swift.swift-corelibs-dev";
  49. stop;
  50. }
  51. if header :contains "List-ID" "<swift-dev.swift.org>" {
  52. fileinto "INBOX.Swift.swift-dev";
  53. stop;
  54. }
  55. if header :contains "List-ID" "<swift-build-dev.swift.org>" {
  56. fileinto "INBOX.Swift.swift-build-dev";
  57. stop;
  58. }
  59. if header :contains "List-ID" "<swift-evolution-announce.swift.org>" {
  60. fileinto "INBOX.Swift.swift-evolution-announce";
  61. stop;
  62. }
  63.  
  64. # GitHub
  65. if allof (
  66. address :is :domain "Message-ID" "github.com",
  67. address :regex :localpart "Message-ID" "^[^/]*/[^/]*/(pull|issues|issue|commit)/"
  68. ) {
  69. # Message-IDs:
  70. # PR: <rust-lang/rust/pull/11967@github.com>
  71. # PR comment: <rust-lang/rust/pull/11967/r9364118@github.com>
  72. # PR event: <rust-lang/rust/pull/17195/issue_event/165199273@github.com>
  73. # Commit comment: <rust-lang/rust/commit/a8a4de50592d97f576064948751b41a5e75092fa/5245928@github.com>
  74. # Issue: <fish-shell/fish-shell/issues/1682@github.com>
  75. # Issue comment: <rust-lang/rust/issues/9575/33858796@github.com>
  76. # Issue event: <rust-lang/rust/issue/9314/issue_event/165582501@github.com>
  77. #
  78. # Comments on issues I'm participating in have X-GitHub-Reason that includes the reason
  79. # that I'm participating (author, comment, mention).
  80.  
  81. # Save all issue events in a folder so we can see them in conversations.
  82. if address :regex :localpart "Message-ID" "^[^/]+/[^/]+/(pull|issue)/[^/]+/issue_event/" {
  83. setflag "\\Seen";
  84. fileinto "INBOX.GitHub.events";
  85. stop;
  86. }
  87.  
  88. # Flag comments on things I authored
  89. if header :is ["X-GitHub-Reason"] "author" {
  90. setflag "\\Flagged";
  91. }
  92.  
  93. # fish-shell
  94. if address :matches :localpart "Message-ID" "fish-shell/*" {
  95. # fish-shell
  96. if address :matches :localpart "Message-ID" "fish-shell/fish-shell/*" {
  97. # PRs
  98. if address :matches :localpart "Message-ID" "fish-shell/fish-shell/pull/*" {
  99. if allof (
  100. address :matches :localpart "Message-ID" "fish-shell/fish-shell/pull/*/*",
  101. not exists ["X-GitHub-Reason"]
  102. ) {
  103. fileinto "INBOX.GitHub.fish-shell.fish-shell.pulls.replies";
  104. } else {
  105. fileinto "INBOX.GitHub.fish-shell.fish-shell.pulls";
  106. }
  107. }
  108. # Issues
  109. elsif address :matches :localpart "Message-ID" "fish-shell/fish-shell/issues/*" {
  110. if allof (
  111. address :matches :localpart "Message-ID" "fish-shell/fish-shell/issues/*/*",
  112. not exists ["X-GitHub-Reason"]
  113. ) {
  114. fileinto "INBOX.GitHub.fish-shell.fish-shell.issues.replies";
  115. } else {
  116. fileinto "INBOX.GitHub.fish-shell.fish-shell.issues";
  117. }
  118. }
  119. # Commit comments
  120. elsif address :matches :localpart "Message-ID" "fish-shell/fish-shell/commit/*" {
  121. fileinto "INBOX.GitHub.fish-shell.fish-shell.comments";
  122. }
  123. # Issue events are handled above
  124. # Unknown formats (may be thrown out later, save them for now)
  125. else {
  126. fileinto "INBOX.GitHub.unknown";
  127. }
  128. }
  129. # anything else
  130. else {
  131. fileinto "INBOX.GitHub.fish-shell.other";
  132. }
  133. }
  134. # rust-lang
  135. elsif address :matches :localpart "Message-ID" "rust-lang/*" {
  136. # bors
  137. if header :is ["From"] "bors <notifications@github.com>" {
  138. # keep failure comments
  139. if not body :text :contains "failure:" {
  140. # temporarily store bors activity into a folder for testing later
  141. fileinto "INBOX.GitHub.rust-lang.bors";
  142. stop;
  143. }
  144. }
  145.  
  146. # rust
  147. if address :matches :localpart "Message-ID" "rust-lang/rust/*" {
  148. # PRs
  149. if address :matches :localpart "Message-ID" "rust-lang/rust/pull/*" {
  150. if allof (
  151. address :matches :localpart "Message-ID" "rust-lang/rust/pull/*/*",
  152. not exists ["X-GitHub-Reason"]
  153. ) {
  154. fileinto "INBOX.GitHub.rust-lang.rust.pulls.replies";
  155. } else {
  156. fileinto "INBOX.GitHub.rust-lang.rust.pulls";
  157. }
  158. }
  159. # Issues
  160. elsif address :matches :localpart "Message-ID" "rust-lang/rust/issues/*" {
  161. if allof (
  162. address :matches :localpart "Message-ID" "rust-lang/rust/issues/*/*",
  163. not exists ["X-GitHub-Reason"]
  164. ) {
  165. fileinto "INBOX.GitHub.rust-lang.rust.issues.replies";
  166. } else {
  167. fileinto "INBOX.GitHub.rust-lang.rust.issues";
  168. }
  169. }
  170. # Commit comments
  171. elsif address :matches :localpart "Message-ID" "rust-lang/rust/commit/*" {
  172. fileinto "INBOX.GitHub.rust-lang.rust.comments";
  173. }
  174. # Issue events are handled above
  175. # Unknown formats (may be thrown out later, save them for now)
  176. else {
  177. fileinto "INBOX.GitHub.unknown";
  178. }
  179. }
  180. # rfcs
  181. elsif address :matches :localpart "Message-ID" "rust-lang/rfcs/*" {
  182. # PRs
  183. if address :matches :localpart "Message-ID" "rust-lang/rfcs/pull/*" {
  184. if allof (
  185. address :matches :localpart "Message-ID" "rust-lang/rfcs/pull/*/*",
  186. not exists ["X-GitHub-Reason"]
  187. ) {
  188. fileinto "INBOX.GitHub.rust-lang.rfcs.pulls.replies";
  189. } else {
  190. fileinto "INBOX.GitHub.rust-lang.rfcs.pulls";
  191. }
  192. }
  193. # Issues
  194. elsif address :matches :localpart "Message-ID" "rust-lang/rfcs/issues/*" {
  195. if allof (
  196. address :matches :localpart "Message-ID" "rust-lang/rfcs/issues/*/*",
  197. not exists ["X-GitHub-Reason"]
  198. ) {
  199. fileinto "INBOX.GitHub.rust-lang.rfcs.issues.replies";
  200. } else {
  201. fileinto "INBOX.GitHub.rust-lang.rfcs.issues";
  202. }
  203. }
  204. # Commit comments
  205. elsif address :matches :localpart "Message-ID" "rust-lang/rfcs/commit/*" {
  206. fileinto "INBOX.GitHub.rust-lang.rfcs.comments";
  207. }
  208. # Issue events are handled above
  209. # Unknown formats (may be thrown out later, save them for now)
  210. else {
  211. fileinto "INBOX.GitHub.unknown";
  212. }
  213. }
  214. # guidelines
  215. elsif address :matches :localpart "Message-ID" "rust-lang/guidelines/*" {
  216. # PRs
  217. if address :matches :localpart "Message-ID" "rust-lang/guidelines/pull/*" {
  218. if allof (
  219. address :matches :localpart "Message-ID" "rust-lang/guidelines/pull/*/*",
  220. not exists ["X-GitHub-Reason"]
  221. ) {
  222. fileinto "INBOX.GitHub.rust-lang.guidelines.pulls.replies";
  223. } else {
  224. fileinto "INBOX.GitHub.rust-lang.guidelines.pulls";
  225. }
  226. }
  227. # Issues
  228. elsif address :matches :localpart "Message-ID" "rust-lang/guidelines/issues/*" {
  229. if allof (
  230. address :matches :localpart "Message-ID" "rust-lang/guidelines/issues/*/*",
  231. not exists ["X-GitHub-Reason"]
  232. ) {
  233. fileinto "INBOX.GitHub.rust-lang.guidelines.issues.replies";
  234. } else {
  235. fileinto "INBOX.GitHub.rust-lang.guidelines.issues";
  236. }
  237. }
  238. # Commit comments
  239. elsif address :matches :localpart "Message-ID" "rust-lang/guidelines/commit/*" {
  240. fileinto "INBOX.GitHub.rust-lang.guidelines.comments";
  241. }
  242. # Issue events are handled above
  243. # Unknown formats (may be thrown out later, save them for now)
  244. else {
  245. fileinto "INBOX.GitHub.unknown";
  246. }
  247. }
  248. # everything else
  249. else {
  250. # PRs
  251. if address :regex :localpart "Message-ID" "^rust-lang/[^/]+/pull/" {
  252. if anyof (
  253. address :regex :localpart "Message-ID" "^rust-lang/[^/]+/pull/[^/]+$",
  254. exists ["X-GitHub-Reason"]
  255. ) {
  256. fileinto "INBOX.GitHub.rust-lang.other.pulls";
  257. } else {
  258. fileinto "INBOX.GitHub.rust-lang.other.pulls.replies";
  259. }
  260. }
  261. # Issues
  262. elsif address :regex :localpart "Message-ID" "^rust-lang/[^/]+/issues/" {
  263. if anyof (
  264. address :regex :localpart "Message-ID" "^rust-lang/[^/]+/issues/[^/]+$",
  265. exists ["X-GitHub-Reason"]
  266. ) {
  267. fileinto "INBOX.GitHub.rust-lang.other.issues";
  268. } else {
  269. fileinto "INBOX.GitHub.rust-lang.other.issues.replies";
  270. }
  271. }
  272. # Commit comments
  273. elsif address :regex :localpart "Message-ID" "^rust-lang/[^/]+/commit/" {
  274. fileinto "INBOX.GitHub.rust-lang.other.comments";
  275. }
  276. # Issue events are handled above
  277. # Unknown formats (may be thrown out later, save them for now)
  278. else {
  279. fileinto "INBOX.GitHub.unknown";
  280. }
  281. }
  282. }
  283. # rust-lang-nursery
  284. elsif address :matches :localpart "Message-ID" "rust-lang-nursery/*" {
  285. # PRs
  286. if address :regex :localpart "Message-ID" "^rust-lang-nursery/[^/]+/pull/" {
  287. if anyof (
  288. address :regex :localpart "Message-ID" "^rust-lang-nursery/[^/]+/pull/[^/]+$",
  289. exists ["X-GitHub-Reason"]
  290. ) {
  291. fileinto "INBOX.GitHub.rust-lang-nursery.pulls";
  292. } else {
  293. fileinto "INBOX.GitHub.rust-lang-nursery.pulls.replies";
  294. }
  295. }
  296. # Issues
  297. elsif address :regex :localpart "Message-ID" "^rust-lang-nursery/[^/]+/issues/" {
  298. if anyof (
  299. address :regex :localpart "Message-ID" "^rust-lang-nursery/[^/]+/issues/[^/]+$",
  300. exists ["X-GitHub-Reason"]
  301. ) {
  302. fileinto "INBOX.GitHub.rust-lang-nursery.issues";
  303. } else {
  304. fileinto "INBOX.GitHub.rust-lang-nursery.issues.replies";
  305. }
  306. }
  307. # Commit comments
  308. elsif address :regex :localpart "Message-ID" "^rust-lang-nursery/[^/]+/commit/" {
  309. fileinto "INBOX.GitHub.rust-lang-nursery.comments";
  310. }
  311. # Issue events are handled above
  312. # Unknown formats
  313. else {
  314. fileinto "INBOX.GitHub.rust-lang-nursery.unknown";
  315. }
  316. }
  317. # Any other GitHub emails can stay in the inbox
  318. else {
  319. keep;
  320. }
  321.  
  322. # Also keep anything that mentions me by name
  323. if body :text :contains "@kballard" {
  324. keep;
  325. }
  326.  
  327. stop;
  328. }
  329.  
  330. # Patreon
  331. if address :is :all "From" "bingo@patreon.com" {
  332. fileinto "INBOX.#Patreon";
  333. stop;
  334. }
  335.  
  336. # Kickstarter Project Updates
  337. if allof (
  338. address :is :all "From" "no-reply@kickstarter.com",
  339. header :matches ["Subject"] "Project Update #*"
  340. ) {
  341. fileinto "INBOX.#Kickstarter";
  342. stop;
  343. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement