From ee6a57ab2012cf05cbb7ade25794b053c3e77ea6 Mon Sep 17 00:00:00 2001 From: Deniz Dogan Date: Wed, 9 Feb 2011 01:22:01 +0100 Subject: [PATCH] * lisp/net/rcirc.el (rcirc-cmd-ctcp): Use dedicated function when available. (rcirc-ctcp-sender-PING): New function. --- lisp/ChangeLog | 6 ++++++ lisp/net/rcirc.el | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 101ea1d20bb..4e0dc57c1b7 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2011-02-09 Deniz Dogan + + * net/rcirc.el (rcirc-cmd-ctcp): Use dedicated function when + available. + (rcirc-ctcp-sender-PING): New function. + 2011-02-08 Stefan Monnier * obsolete/pc-select.el: Rename from emulation/pc-select.el (bug#7940). diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 21934ce8b01..246f6335134 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -2185,14 +2185,23 @@ With a prefix arg, prompt for new topic." (defun rcirc-cmd-ctcp (args &optional process target) (if (string-match "^\\([^ ]+\\)\\s-+\\(.+\\)$" args) - (let ((target (match-string 1 args)) - (request (match-string 2 args))) - (rcirc-send-string process - (format "PRIVMSG %s \C-a%s\C-a" - target (upcase request)))) + (let* ((target (match-string 1 args)) + (request (upcase (match-string 2 args))) + (function (intern-soft (concat "rcirc-ctcp-sender-" request)))) + (if (fboundp function) ;; use special function if available + (funcall function process target request) + (rcirc-send-string process + (format "PRIVMSG %s :\C-a%s\C-a" + target request)))) (rcirc-print process (rcirc-nick process) "ERROR" nil "usage: /ctcp NICK REQUEST"))) +(defun rcirc-ctcp-sender-PING (process target request) + "Send a CTCP PING message to TARGET." + (let ((timestamp (car (split-string (number-to-string (float-time)) "\\.")))) + (rcirc-send-string process + (format "PRIVMSG %s :\C-aPING %s\C-a" target timestamp)))) + (defun rcirc-cmd-me (args &optional process target) (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a" target args))) -- 2.39.5