Skip to content

Instantly share code, notes, and snippets.

@Licenser
Forked from Raynes/dictionary.clj
Created April 28, 2010 11:02
Show Gist options
  • Save Licenser/382010 to your computer and use it in GitHub Desktop.
Save Licenser/382010 to your computer and use it in GitHub Desktop.
(defn answer-with [irc-data reply]
(let [{:keys [irc channel nick]} irc-data]
(ircb/send-message irc channel
(str nick ": " reply)))
(defplugin
(:dict
"Takes a word and look's up it's definition via the Wordnik dictionary API."
["dict"]
[{:keys [irc channel nick args] :as data}]
(answer-with data
(let [[text part] (lookup-def (first args))]
(if (seq text) (str part ": " text) "Word not found.")))))
(defn answer-to [irc-data f]
(let [{:keys [irc channel nick]} irc-data]
(ircb/send-message irc channel
(str nick ": " (f irc-data))))
(defplugin
(:dict
"Takes a word and look's up it's definition via the Wordnik dictionary API."
["dict"]
[{:keys [irc channel nick args] :as data}]
(answer-to data (fn [{:keys [args]}]
(let [[text part] (lookup-def (first args))]
(if (seq text) (str part ": " text) "Word not found."))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment