Created
October 18, 2010 17:51
-
-
Save ninjudd/632664 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns sexpbot.plugins.logger | |
| (:use [sexpbot respond] | |
| [clj-time.core :only [now]] | |
| [clj-time.formatters :only [unparse formatters]]) | |
| (:import [java.io File])) | |
| (defplugin | |
| (:hook | |
| :on-message | |
| (fn [{:keys [bot nick channel message]}] | |
| (let [config (:config @bot)] | |
| (if (get-in config [:log channel]) | |
| (let [log-dir (File. (:log-dir config) channel) | |
| date (unparse (formatters :date) (now)) | |
| time (unparse (formatters :time) (now))] | |
| (spit (File. log-dir (str date ".txt")) | |
| (format "%s: %s: %s\n" time nick message) | |
| :append true))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment