Skip to content

Instantly share code, notes, and snippets.

@devth
Created September 18, 2012 20:03
Show Gist options
  • Save devth/3745499 to your computer and use it in GitHub Desktop.
Save devth/3745499 to your computer and use it in GitHub Desktop.
Expansion of YetiBot's cmd-hook
;;; Expansion of YetiBot's cmd-hook
;;; https://github.com/devth/yetibot/blob/master/src/yetibot/util.clj#L16-48
(clojure.pprint/pprint
(macroexpand '(cmd-hook #"wordnik"
#"define\s(\w+)" (define (second p))
#"random" (random)
#"wotd" (wotd))))
;;; result
(do
(robert.hooke/add-hook
#'yetibot.core/handle-command
(clojure.core/fn
[callback cmd args user]
(if
(clojure.core/re-find
#"wordnik"
(clojure.contrib.string/lower-case cmd))
(do
(clojure.core/println
(clojure.core/str
"found " #"wordnik" " on cmd " cmd ". args are:" args))
(clojure.contrib.cond/cond-let
[p]
(clojure.core/re-find #"define\s(\w+)" args)
(define (second p))
(clojure.core/re-find #"random" args)
(random)
(clojure.core/re-find #"wotd" args)
(wotd)
true
(yetibot.core/handle-command
"help"
(clojure.core/str #"wordnik"))))
(callback cmd args user))))
(yetibot.models.help/add-docs
#"wordnik"
(clojure.core/map
(clojure.core/fn
[i__3642__auto__]
(if
(clojure.core/list? i__3642__auto__)
(:doc
(clojure.core/meta
(clojure.core/resolve (clojure.core/first i__3642__auto__))))))
'(#"define\s(\w+)"
(define (second p))
#"random"
(random)
#"wotd"
(wotd)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment