Skip to content

Instantly share code, notes, and snippets.

Created July 25, 2012 03:34
Show Gist options
  • Save anonymous/3174213 to your computer and use it in GitHub Desktop.
Save anonymous/3174213 to your computer and use it in GitHub Desktop.
(defvar rcirc-max-message-length 420
"Messages longer than this value will be split.")
(defun rcirc-send-message (process target message &optional noticep silent)
"Send TARGET associated with PROCESS a privmsg with text MESSAGE.
If NOTICEP is non-nil, send a notice instead of privmsg.
If SILENT is non-nil, do not print the message in any irc buffer."
;; max message length is 512 including CRLF
(let* ((response (if noticep "NOTICE" "PRIVMSG"))
(oversize (> (length message) rcirc-max-message-length))
(text (if oversize
(substring message 0 rcirc-max-message-length)
message))
(text (if (string= text "")
" "
text))
(more (if oversize
(substring message rcirc-max-message-length))))
(rcirc-get-buffer-create process target)
(rcirc-send-string process (concat response " " target " :" text))
(unless silent
(rcirc-print process (rcirc-nick process) response target text))
(when more (rcirc-send-message process target more noticep))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment