rlm@0: ":";exec java -cp $HOME/roBin/src:$HOME/roBin/lib/* clojure.main $0 $*; rlm@0: rlm@0: (ns rlm.kitchen-mailer rlm@0: "This program runs every day as a cron job to remind people rlm@0: to clean the tetazoo kitchen. Everyone with a cabinet must rlm@0: clean the kitchen." rlm@0: {:author "Robert McIntyre"} rlm@0: (:use [com.draines.postal [core :only [send-message]]] rlm@0: [rlm [shell-inspect :only [command-line?]]]) rlm@0: (:import [org.joda.time Days DateMidnight])) rlm@0: rlm@0: (defn start-day [] (DateMidnight. 2011 2 13)) rlm@0: rlm@0: (def cabinets rlm@0: [["deborahc"] rlm@0: ["maponte"] rlm@0: ["k_french"] rlm@0: ["clarkds"] rlm@0: ["kharring"] rlm@0: ["jasminef"] rlm@0: ["kerrynic"] rlm@0: ["guertin"] rlm@0: ["ervanalb"] rlm@0: ["tayral13"] rlm@0: ["rbowru"] rlm@0: ["lexrj"] rlm@0: ["viccro"] rlm@0: ["kfish"] rlm@0: ["k8r" "infrared"] rlm@0: ["verdant"] rlm@0: ["greener"] rlm@0: ["phulin"] rlm@0: ["slehmann"] rlm@0: ["acrefoot"] rlm@0: ["oliviame"]]) rlm@0: rlm@0: (def kitchen-reminder rlm@0: {:from "kitchen-bitch-bot@rlmcintyre.com" rlm@0: :cc [ "rlm@mit.edu" "slehmann@mit.edu" ] rlm@0: :subject "It's your turn to clean the kitchen" rlm@0: :body " rlm@0: It's your day to clean the kitchen. rlm@0: If it isn't clean by 23:00, I will not hesitate to rlm@0: hunt you down/wake you up/pry you away from your p-set. rlm@0: rlm@0: <3, Kitchen Bitch rlm@0: rlm@0: -------------------------------------------- rlm@0: This mailer is open source and all that; you can see the source at rlm@0: http://www.rlmcintyre.com/kitchen-bitch.txt"}) rlm@0: rlm@0: (defn get-current-date [] (DateMidnight.)) rlm@0: rlm@0: (defn days-since-start-day [start-day end-day] rlm@0: (.getDays (Days/daysBetween start-day end-day))) rlm@0: rlm@0: (defn mail-a-tetazoan rlm@0: "tetazoan will be a username like kfish, with the \"@mit.edu\" implied." rlm@0: [tetazoan message] rlm@0: (if-not (nil? tetazoan) rlm@0: (let [message (merge message {:to (into [] (map #(str % "@mit.edu") tetazoan))})] rlm@0: (println message) rlm@0: (send-message message)))) rlm@0: rlm@0: (defn target-person [] rlm@0: (cabinets rlm@0: (rem (days-since-start-day (start-day) (get-current-date)) rlm@0: (count cabinets)))) rlm@0: rlm@0: (defn main [] rlm@0: (println "mailing " (target-person)) rlm@0: ;; (println (mail-a-tetazoan (target-person) kitchen-reminder)) rlm@0: ) rlm@0: rlm@0: (if (command-line?) (main))