Mercurial > rlm
view 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 |
line wrap: on
line source
1 ":";exec java -cp $HOME/roBin/src:$HOME/roBin/lib/* clojure.main $0 $*;3 (ns rlm.kitchen-mailer4 "This program runs every day as a cron job to remind people5 to clean the tetazoo kitchen. Everyone with a cabinet must6 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]))12 (defn start-day [] (DateMidnight. 2011 2 13))14 (def cabinets15 [["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"]])37 (def kitchen-reminder38 {: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 to44 hunt you down/wake you up/pry you away from your p-set.46 <3, Kitchen Bitch48 --------------------------------------------49 This mailer is open source and all that; you can see the source at50 http://www.rlmcintyre.com/kitchen-bitch.txt"})52 (defn get-current-date [] (DateMidnight.))54 (defn days-since-start-day [start-day end-day]55 (.getDays (Days/daysBetween start-day end-day)))57 (defn mail-a-tetazoan58 "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))))65 (defn target-person []66 (cabinets67 (rem (days-since-start-day (start-day) (get-current-date))68 (count cabinets))))70 (defn main []71 (println "mailing " (target-person))72 ;; (println (mail-a-tetazoan (target-person) kitchen-reminder))73 )75 (if (command-line?) (main))