Skip to content

Instantly share code, notes, and snippets.

@dakrone
Created March 24, 2011 04:06
Show Gist options
  • Select an option

  • Save dakrone/884561 to your computer and use it in GitHub Desktop.

Select an option

Save dakrone/884561 to your computer and use it in GitHub Desktop.
;; taken from src/subrosa/commands.clj
(defcommand privmsg [channel args]
(let [[recipient received-msg] (.split args " " 2)
msg (format ":%s PRIVMSG %s %s"
(format-client channel) recipient received-msg)]
(if (not (empty? recipient))
(if (not (nil? received-msg))
(if (room-for-name recipient)
(do
(send-to-room-except recipient msg channel)
(run-hook 'privmsg-room-hook
channel recipient (subs received-msg 1)))
(if-let [channel (channel-for-nick recipient)]
(do
(send-to-client* channel msg)
(run-hook 'privmsg-nick-hook
channel recipient (subs received-msg 1)))
(raise {:type :client-error
:code 401
:msg (format "%s :No such nick/channel" recipient)})))
(raise {:type :client-error
:code 412
:msg ":No text to send"}))
(raise {:type :client-error
:code 411
:msg ":No recipient given (PRIVMSG)"}))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment