Skip to content

Instantly share code, notes, and snippets.

@ninjudd
Created October 18, 2010 17:51
Show Gist options
  • Select an option

  • Save ninjudd/632664 to your computer and use it in GitHub Desktop.

Select an option

Save ninjudd/632664 to your computer and use it in GitHub Desktop.
(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