Mercurial > rlm
comparison src/rlm/kitchen_mailer.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:78a630e650d2 |
---|---|
1 ":";exec java -cp $HOME/roBin/src:$HOME/roBin/lib/* clojure.main $0 $*; | |
2 | |
3 (ns rlm.kitchen-mailer | |
4 "This program runs every day as a cron job to remind people | |
5 to clean the tetazoo kitchen. Everyone with a cabinet must | |
6 clean the kitchen." | |
7 {:author "Robert McIntyre"} | |
8 (:use [com.draines.postal [core :only [send-message]]] | |
9 [rlm [shell-inspect :only [command-line?]]]) | |
10 (:import [org.joda.time Days DateMidnight])) | |
11 | |
12 (defn start-day [] (DateMidnight. 2011 2 13)) | |
13 | |
14 (def cabinets | |
15 [["deborahc"] | |
16 ["maponte"] | |
17 ["k_french"] | |
18 ["clarkds"] | |
19 ["kharring"] | |
20 ["jasminef"] | |
21 ["kerrynic"] | |
22 ["guertin"] | |
23 ["ervanalb"] | |
24 ["tayral13"] | |
25 ["rbowru"] | |
26 ["lexrj"] | |
27 ["viccro"] | |
28 ["kfish"] | |
29 ["k8r" "infrared"] | |
30 ["verdant"] | |
31 ["greener"] | |
32 ["phulin"] | |
33 ["slehmann"] | |
34 ["acrefoot"] | |
35 ["oliviame"]]) | |
36 | |
37 (def kitchen-reminder | |
38 {:from "kitchen-bitch-bot@rlmcintyre.com" | |
39 :cc [ "rlm@mit.edu" "slehmann@mit.edu" ] | |
40 :subject "It's your turn to clean the kitchen" | |
41 :body " | |
42 It's your day to clean the kitchen. | |
43 If it isn't clean by 23:00, I will not hesitate to | |
44 hunt you down/wake you up/pry you away from your p-set. | |
45 | |
46 <3, Kitchen Bitch | |
47 | |
48 -------------------------------------------- | |
49 This mailer is open source and all that; you can see the source at | |
50 http://www.rlmcintyre.com/kitchen-bitch.txt"}) | |
51 | |
52 (defn get-current-date [] (DateMidnight.)) | |
53 | |
54 (defn days-since-start-day [start-day end-day] | |
55 (.getDays (Days/daysBetween start-day end-day))) | |
56 | |
57 (defn mail-a-tetazoan | |
58 "tetazoan will be a username like kfish, with the \"@mit.edu\" implied." | |
59 [tetazoan message] | |
60 (if-not (nil? tetazoan) | |
61 (let [message (merge message {:to (into [] (map #(str % "@mit.edu") tetazoan))})] | |
62 (println message) | |
63 (send-message message)))) | |
64 | |
65 (defn target-person [] | |
66 (cabinets | |
67 (rem (days-since-start-day (start-day) (get-current-date)) | |
68 (count cabinets)))) | |
69 | |
70 (defn main [] | |
71 (println "mailing " (target-person)) | |
72 ;; (println (mail-a-tetazoan (target-person) kitchen-reminder)) | |
73 ) | |
74 | |
75 (if (command-line?) (main)) |