From 1be1d1e98e5465659b9633a3f1961e6dcc0b022a Mon Sep 17 00:00:00 2001 From: Deniz Dogan Date: Thu, 10 Feb 2011 16:41:40 +0100 Subject: [PATCH] * lisp/net/rcirc.el: Add PRIVMSG and CTCP functions. (rcirc-send-privmsg, rcirc-send-ctcp): New functions. (rcirc-keepalive, rcirc-cmd-ctcp, rcirc-ctcp-sender-PING) (rcirc-cmd-me, rcirc-authenticate): Use them. --- lisp/ChangeLog | 7 +++++++ lisp/net/rcirc.el | 50 +++++++++++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 1a69d98f17e..e9e7f6203b1 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2011-02-10 Deniz Dogan + + * net/rcirc.el: Add PRIVMSG and CTCP functions. + (rcirc-send-privmsg, rcirc-send-ctcp): New functions. + (rcirc-keepalive, rcirc-cmd-ctcp, rcirc-ctcp-sender-PING) + (rcirc-cmd-me, rcirc-authenticate): Use them. + 2011-02-10 Ken Manheimer * allout.el: Synopsis: Change allout user configuration so diff --git a/lisp/net/rcirc.el b/lisp/net/rcirc.el index 62fa7eb0feb..f0581838c48 100644 --- a/lisp/net/rcirc.el +++ b/lisp/net/rcirc.el @@ -564,13 +564,13 @@ last ping." (mapc (lambda (process) (with-rcirc-process-buffer process (when (not rcirc-connecting) - (rcirc-send-string process - (format "PRIVMSG %s :\C-aKEEPALIVE %f\C-a" - rcirc-nick - (if (featurep 'xemacs) - (time-to-seconds - (current-time)) - (float-time))))))) + (rcirc-send-ctcp process + rcirc-nick + (format "KEEPALIVE %f" + (if (featurep 'xemacs) + (time-to-seconds + (current-time)) + (float-time))))))) (rcirc-process-list)) ;; no processes, clean up timer (cancel-timer rcirc-keepalive-timer) @@ -714,6 +714,14 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.") (rcirc-debug process string) (process-send-string process string))) +(defun rcirc-send-privmsg (process target string) + (rcirc-send-string process (format "PRIVMSG %s :%s" target string))) + +(defun rcirc-send-ctcp (process target request &optional args) + (let ((args (if args (concat " " args) ""))) + (rcirc-send-privmsg process target + (format "\C-a%s%s\C-a" request args "")))) + (defun rcirc-buffer-process (&optional buffer) "Return the process associated with channel BUFFER. With no argument or nil as argument, use the current buffer." @@ -2190,21 +2198,17 @@ With a prefix arg, prompt for new topic." (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-send-ctcp process 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 (format "%.0f" (float-time)))) - (rcirc-send-string process - (format "PRIVMSG %s :\C-aPING %s\C-a" target timestamp)))) + (rcirc-send-ctcp process target "PING" timestamp))) (defun rcirc-cmd-me (args &optional process target) - (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a" - target args))) + (rcirc-send-ctcp process target "ACTION" args)) (defun rcirc-add-or-remove (set &rest elements) (dolist (elt elements) @@ -2699,20 +2703,20 @@ Passwords are stored in `rcirc-authinfo' (which see)." (when (and (string-match server rcirc-server) (string-match nick rcirc-nick)) (cond ((equal method 'nickserv) - (rcirc-send-string + (rcirc-send-privmsg process - (concat "PRIVMSG " (or (cadr args) "nickserv") - " :identify " (car args)))) + (or (cadr args) "NickServ") + (concat "identify " (car args)))) ((equal method 'chanserv) - (rcirc-send-string + (rcirc-send-privmsg process - (concat - "PRIVMSG chanserv :identify " - (car args) " " (cadr args)))) + "ChanServ" + (format "identify %s %s" (car args) (cadr args)))) ((equal method 'bitlbee) - (rcirc-send-string + (rcirc-send-privmsg process - (concat "PRIVMSG &bitlbee :identify " (car args)))) + "&bitlbee" + (concat "identify " (car args)))) (t (message "No %S authentication method defined" method))))))))