Created
April 18, 2010 03:33
-
-
Save devn/369979 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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