Created
February 9, 2012 18:38
-
-
Save hagna/1781893 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
(ns bot1.core | |
(import (org.jibble.pircbot PircBot)) | |
(require hobbit.bitly) | |
(import (hobbit.bitly Bitly))) | |
(def *bot*) | |
(def url-regex #"[A-Za-z]+://[^ ^/]+\.[^ ^/]+[^ ]+") | |
(defn sendMsg "send a message to a recv, a recv is a channel name or a nick" | |
[this recv msg] | |
(.sendMessage this recv (.replace (str msg) \newline \ ))) | |
(def *bitly* (hobbit.bitly/Bitly. "a" "b" "c")) | |
(defn handleMessage [channel sender login hostname message] | |
(let [url (re-find url-regex message)] | |
(println url))) | |
(defn pircbot [] | |
(proxy [PircBot] [] | |
(onMessage [channel sender login hostname message] | |
(handleMessage channel sender login hostname message) | |
))) | |
(defn -main [& args] | |
(def *bot* (pircbot)) | |
(.connect *bot* "") | |
(.changeNick *bot* "clojure") | |
(.joinChannel *bot* "#test")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment