;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING. If not, write to the
-;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+;; Boston, MA 02110-1301, USA.
;;; Commentary:
(require 'riece-highlight)
(require 'riece-display)
(require 'riece-debug)
+(require 'riece-mcat)
+(require 'riece-message)
(defface riece-ctcp-action-face
'((((class color)
riece-dialogue-buffer)
(concat
(riece-concat-server-name
- (format "CTCP VERSION from %s (%s) to %s"
+ (format (riece-mcat "CTCP VERSION from %s (%s) to %s")
user
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
(riece-format-identity target-identity t)))
(riece-send-string
(if string
(format "NOTICE %s :\1PING %s\1\r\n" user string)
- (format "NOTICE %s :\1PING\1\r\n" user string)))
+ (format "NOTICE %s :\1PING\1\r\n" user)))
(riece-insert-change buffer (format "CTCP PING from %s\n" user))
(riece-insert-change
(if (and riece-channel-buffer-mode
riece-dialogue-buffer)
(concat
(riece-concat-server-name
- (format "CTCP PING from %s (%s) to %s"
+ (format (riece-mcat "CTCP PING from %s (%s) to %s")
user
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
(riece-format-identity target-identity t)))
riece-dialogue-buffer)
(concat
(riece-concat-server-name
- (format "CTCP CLIENTINFO from %s (%s) to %s"
+ (format (riece-mcat "CTCP CLIENTINFO from %s (%s) to %s")
user
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
(riece-format-identity target-identity t)))
"\n"))))
+(defun riece-ctcp-action-format-message (message &optional global)
+ (riece-with-server-buffer (riece-identity-server
+ (riece-message-speaker message))
+ (concat
+ (if global
+ (riece-concat-server-name
+ (concat riece-ctcp-action-prefix
+ (riece-format-identity (riece-message-target message) t) ": "
+ (riece-identity-prefix (riece-message-speaker message)) " "
+ (riece-message-text message)))
+ (concat riece-ctcp-action-prefix
+ (riece-identity-prefix (riece-message-speaker message)) " "
+ (riece-message-text message)))
+ "\n")))
+
(defun riece-handle-ctcp-action-request (prefix target string)
(let ((buffer (if (riece-channel-p target)
(riece-channel-buffer (riece-make-identity
target riece-server-name))))
(user (riece-prefix-nickname prefix)))
- (riece-insert buffer (concat riece-ctcp-action-prefix
- (riece-format-identity
- (riece-make-identity user riece-server-name)
- t)
- " " string
- "\n"))
- (riece-insert
- (if (and riece-channel-buffer-mode
- (not (eq buffer riece-channel-buffer)))
- (list riece-dialogue-buffer riece-others-buffer)
- riece-dialogue-buffer)
- (concat (riece-concat-server-name
- (concat riece-ctcp-action-prefix
- (riece-format-identity
- (riece-make-identity target riece-server-name)
- t)
- ": "
- (riece-format-identity
- (riece-make-identity user riece-server-name)
- t)
- " " string)) "\n"))))
+ (riece-display-message
+ (riece-make-message (riece-make-identity user
+ riece-server-name)
+ (riece-make-identity target
+ riece-server-name)
+ string
+ 'action
+ (riece-identity-equal-no-server
+ user riece-real-nickname)))))
(defun riece-handle-ctcp-time-request (prefix target string)
(let* ((target-identity (riece-make-identity target riece-server-name))
(time (format-time-string "%c")))
(riece-send-string
(format "NOTICE %s :\1TIME %s\1\r\n" user time))
- (riece-insert-change buffer (format "CTCP TIME from %s\n" user))
+ (riece-insert-change buffer (format (riece-mcat "CTCP TIME from %s\n")
+ user))
(riece-insert-change
(if (and riece-channel-buffer-mode
(not (eq buffer riece-channel-buffer)))
riece-dialogue-buffer)
(concat
(riece-concat-server-name
- (format "CTCP TIME from %s (%s) to %s"
+ (format (riece-mcat "CTCP TIME from %s (%s) to %s")
user
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
(riece-format-identity target-identity t)))
(list riece-dialogue-buffer riece-others-buffer)
(concat
(riece-concat-server-name
- (format "CTCP VERSION for %s (%s) = %s"
+ (format (riece-mcat "CTCP VERSION for %s (%s) = %s")
(riece-prefix-nickname prefix)
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
string))
(list riece-dialogue-buffer riece-others-buffer)
(concat
(riece-concat-server-name
- (format "CTCP PING for %s (%s) = %d sec"
+ (format (riece-mcat "CTCP PING for %s (%s) = %d sec")
(riece-prefix-nickname prefix)
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
elapsed))
(list riece-dialogue-buffer riece-others-buffer)
(concat
(riece-concat-server-name
- (format "CTCP CLIENTINFO for %s (%s) = %s"
+ (format (riece-mcat "CTCP CLIENTINFO for %s (%s) = %s")
(riece-prefix-nickname prefix)
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
string))
(list riece-dialogue-buffer riece-others-buffer)
(concat
(riece-concat-server-name
- (format "CTCP TIME for %s (%s) = %s"
+ (format (riece-mcat "CTCP TIME for %s (%s) = %s")
(riece-prefix-nickname prefix)
(riece-strip-user-at-host (riece-prefix-user-at-host prefix))
string))
(defun riece-command-ctcp-version (target)
(interactive
(list (riece-completing-read-identity
- "Channel/User: "
+ (riece-mcat "Channel/User: ")
(riece-get-identities-on-server (riece-current-server-name)))))
(riece-send-string (format "PRIVMSG %s :\1VERSION\1\r\n"
(riece-identity-prefix target))))
(defun riece-command-ctcp-ping (target)
(interactive
(list (riece-completing-read-identity
- "Channel/User: "
+ (riece-mcat "Channel/User: ")
(riece-get-identities-on-server (riece-current-server-name)))))
(riece-send-string (format "PRIVMSG %s :\1PING\1\r\n"
(riece-identity-prefix target)))
(defun riece-command-ctcp-clientinfo (target)
(interactive
(list (riece-completing-read-identity
- "Channel/User: "
+ (riece-mcat "Channel/User: ")
(riece-get-identities-on-server (riece-current-server-name)))))
(riece-send-string (format "PRIVMSG %s :\1CLIENTINFO\1\r\n"
(riece-identity-prefix target))))
(interactive
(list (if current-prefix-arg
(riece-completing-read-identity
- "Channel/User: "
+ (riece-mcat "Channel/User: ")
(riece-get-identities-on-server (riece-current-server-name)))
riece-current-channel)
(let (message)
(setq message (buffer-substring (point)
(progn (end-of-line) (point))))
(if (equal message "")
- (read-string "Action: ")
- (prog1 (read-from-minibuffer "Action: " (cons message 0))
+ (read-string (riece-mcat "Action: "))
+ (prog1 (read-from-minibuffer (riece-mcat "Action: ")
+ (cons message 0))
(let ((next-line-add-newlines t))
(next-line 1)))))))
(if (equal action "")
(riece-send-string (format "PRIVMSG %s :\1ACTION %s\1\r\n"
(riece-identity-prefix target)
action))
- (let ((buffer (riece-channel-buffer target)))
- (riece-insert
- buffer
- (concat riece-ctcp-action-prefix
- (riece-identity-prefix (riece-current-nickname)) " " action "\n"))
- (riece-insert
- (if (and riece-channel-buffer-mode
- (not (eq buffer riece-channel-buffer)))
- (list riece-dialogue-buffer riece-others-buffer)
- riece-dialogue-buffer)
- (concat
- (riece-with-server-buffer (riece-identity-server target)
- (riece-concat-server-name
- (concat riece-ctcp-action-prefix
- (riece-format-identity target t) ": "
- (riece-identity-prefix (riece-current-nickname)) " " action)))
- "\n"))))
+ (riece-display-message
+ (riece-make-message (riece-current-nickname) target action 'action t)))
(defun riece-command-ctcp-time (target)
(interactive
(list (riece-completing-read-identity
- "Channel/User: "
+ (riece-mcat "Channel/User: ")
(riece-get-identities-on-server (riece-current-server-name)))))
(riece-send-string (format "PRIVMSG %s :\1TIME\1\r\n"
(riece-identity-prefix target))))
(if (memq 'riece-highlight riece-addons)
(setq riece-dialogue-font-lock-keywords
(cons riece-ctcp-dialogue-font-lock-keywords
- riece-dialogue-font-lock-keywords))))
+ riece-dialogue-font-lock-keywords)))
+ (unless (assq 'action riece-message-format-function-alist)
+ (setq riece-message-format-function-alist
+ (cons (cons 'action #'riece-ctcp-action-format-message)
+ riece-message-format-function-alist))))
(defun riece-ctcp-uninstall ()
(remove-hook 'riece-privmsg-hook 'riece-handle-ctcp-request)