Created
November 29, 2011 05:22
-
-
Save devth/1403552 to your computer and use it in GitHub Desktop.
This file contains 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
(defn meme-hook [callback cmd args] | |
(if (re-find #"meme" (s/lower-case cmd)) | |
(cond-let [p] | |
(re-find #"^popular$" args) (chat-instance-popular) | |
(re-find #"^trending$" args) (chat-meme-list | |
(gen-trending)) | |
(re-find #"^search\s(.+)" args) (chat-meme-list | |
(search-generators (second p))) | |
(re-find #"(\w+)\s(.+)\/(.+)$" args) (chat-instance | |
(create-instance ; e.g. "meme yuno line1 / line2" | |
(map-to-query-string | |
(build-instance-params | |
(nth p 1) (nth p 2) (nth p 3))))) | |
:else (callback cmd args)))) | |
(rh/add-hook #'core/handle-command meme-hook) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment