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