Skip to content

Instantly share code, notes, and snippets.

@devn
Created April 18, 2010 03:33
Show Gist options
  • Select an option

  • Save devn/369979 to your computer and use it in GitHub Desktop.

Select an option

Save devn/369979 to your computer and use it in GitHub Desktop.
(defn check-user
"Checks the nickname of the user. This functions as a basic authorization check for commands like \"!join\"."
[nick f]
(if (= nick "defn")
f
nil))
(def bot-fnmap
{:on-message
(fn [{:keys [nick channel message irc]}]
(let [[cmd & more] (.split message " ")]
(condp = cmd
"!join" (check-user nick (join-chan irc (first more)))
#".*" (send-message irc #"defn-bot" (str nick " wtf are you talking about?")))))
:on-quit (fn [{:keys [nick reason irc]}]
(send-message irc "#defn-bot" (str nick " quit. His reason was: " reason)))
:on-part (fn [{:keys [nick reason channel irc]}]
(send-message irc channel (str nick " parted. Reason: " reason)))})
(def bot
(connect
(create-irc
{:name "defn-bot",
:server "irc.freenode.net",
:username "defn-bot",
:port 6667,
:realname "defn-bot"
:fnmap bot-fnmap})
:channels ["#defn-bot"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment