diff options
| author | Deniz Dogan | 2011-02-10 16:41:40 +0100 |
|---|---|---|
| committer | Deniz Dogan | 2011-02-10 16:41:40 +0100 |
| commit | 1be1d1e98e5465659b9633a3f1961e6dcc0b022a (patch) | |
| tree | f41d8acf6b8f074db0260dc63763589d51b31955 /lisp | |
| parent | 67f02b82f496be403353a1dc918cc4f2278841bb (diff) | |
| download | emacs-1be1d1e98e5465659b9633a3f1961e6dcc0b022a.tar.gz emacs-1be1d1e98e5465659b9633a3f1961e6dcc0b022a.zip | |
* 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.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | 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 @@ | |||
| 1 | 2011-02-10 Deniz Dogan <deniz.a.m.dogan@gmail.com> | ||
| 2 | |||
| 3 | * net/rcirc.el: Add PRIVMSG and CTCP functions. | ||
| 4 | (rcirc-send-privmsg, rcirc-send-ctcp): New functions. | ||
| 5 | (rcirc-keepalive, rcirc-cmd-ctcp, rcirc-ctcp-sender-PING) | ||
| 6 | (rcirc-cmd-me, rcirc-authenticate): Use them. | ||
| 7 | |||
| 1 | 2011-02-10 Ken Manheimer <ken.manheimer@gmail.com> | 8 | 2011-02-10 Ken Manheimer <ken.manheimer@gmail.com> |
| 2 | 9 | ||
| 3 | * allout.el: Synopsis: Change allout user configuration so | 10 | * 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." | |||
| 564 | (mapc (lambda (process) | 564 | (mapc (lambda (process) |
| 565 | (with-rcirc-process-buffer process | 565 | (with-rcirc-process-buffer process |
| 566 | (when (not rcirc-connecting) | 566 | (when (not rcirc-connecting) |
| 567 | (rcirc-send-string process | 567 | (rcirc-send-ctcp process |
| 568 | (format "PRIVMSG %s :\C-aKEEPALIVE %f\C-a" | 568 | rcirc-nick |
| 569 | rcirc-nick | 569 | (format "KEEPALIVE %f" |
| 570 | (if (featurep 'xemacs) | 570 | (if (featurep 'xemacs) |
| 571 | (time-to-seconds | 571 | (time-to-seconds |
| 572 | (current-time)) | 572 | (current-time)) |
| 573 | (float-time))))))) | 573 | (float-time))))))) |
| 574 | (rcirc-process-list)) | 574 | (rcirc-process-list)) |
| 575 | ;; no processes, clean up timer | 575 | ;; no processes, clean up timer |
| 576 | (cancel-timer rcirc-keepalive-timer) | 576 | (cancel-timer rcirc-keepalive-timer) |
| @@ -714,6 +714,14 @@ Function is called with PROCESS, COMMAND, SENDER, ARGS and LINE.") | |||
| 714 | (rcirc-debug process string) | 714 | (rcirc-debug process string) |
| 715 | (process-send-string process string))) | 715 | (process-send-string process string))) |
| 716 | 716 | ||
| 717 | (defun rcirc-send-privmsg (process target string) | ||
| 718 | (rcirc-send-string process (format "PRIVMSG %s :%s" target string))) | ||
| 719 | |||
| 720 | (defun rcirc-send-ctcp (process target request &optional args) | ||
| 721 | (let ((args (if args (concat " " args) ""))) | ||
| 722 | (rcirc-send-privmsg process target | ||
| 723 | (format "\C-a%s%s\C-a" request args "")))) | ||
| 724 | |||
| 717 | (defun rcirc-buffer-process (&optional buffer) | 725 | (defun rcirc-buffer-process (&optional buffer) |
| 718 | "Return the process associated with channel BUFFER. | 726 | "Return the process associated with channel BUFFER. |
| 719 | With no argument or nil as argument, use the current buffer." | 727 | With no argument or nil as argument, use the current buffer." |
| @@ -2190,21 +2198,17 @@ With a prefix arg, prompt for new topic." | |||
| 2190 | (function (intern-soft (concat "rcirc-ctcp-sender-" request)))) | 2198 | (function (intern-soft (concat "rcirc-ctcp-sender-" request)))) |
| 2191 | (if (fboundp function) ;; use special function if available | 2199 | (if (fboundp function) ;; use special function if available |
| 2192 | (funcall function process target request) | 2200 | (funcall function process target request) |
| 2193 | (rcirc-send-string process | 2201 | (rcirc-send-ctcp process target request))) |
| 2194 | (format "PRIVMSG %s :\C-a%s\C-a" | ||
| 2195 | target request)))) | ||
| 2196 | (rcirc-print process (rcirc-nick process) "ERROR" nil | 2202 | (rcirc-print process (rcirc-nick process) "ERROR" nil |
| 2197 | "usage: /ctcp NICK REQUEST"))) | 2203 | "usage: /ctcp NICK REQUEST"))) |
| 2198 | 2204 | ||
| 2199 | (defun rcirc-ctcp-sender-PING (process target request) | 2205 | (defun rcirc-ctcp-sender-PING (process target request) |
| 2200 | "Send a CTCP PING message to TARGET." | 2206 | "Send a CTCP PING message to TARGET." |
| 2201 | (let ((timestamp (format "%.0f" (float-time)))) | 2207 | (let ((timestamp (format "%.0f" (float-time)))) |
| 2202 | (rcirc-send-string process | 2208 | (rcirc-send-ctcp process target "PING" timestamp))) |
| 2203 | (format "PRIVMSG %s :\C-aPING %s\C-a" target timestamp)))) | ||
| 2204 | 2209 | ||
| 2205 | (defun rcirc-cmd-me (args &optional process target) | 2210 | (defun rcirc-cmd-me (args &optional process target) |
| 2206 | (rcirc-send-string process (format "PRIVMSG %s :\C-aACTION %s\C-a" | 2211 | (rcirc-send-ctcp process target "ACTION" args)) |
| 2207 | target args))) | ||
| 2208 | 2212 | ||
| 2209 | (defun rcirc-add-or-remove (set &rest elements) | 2213 | (defun rcirc-add-or-remove (set &rest elements) |
| 2210 | (dolist (elt elements) | 2214 | (dolist (elt elements) |
| @@ -2699,20 +2703,20 @@ Passwords are stored in `rcirc-authinfo' (which see)." | |||
| 2699 | (when (and (string-match server rcirc-server) | 2703 | (when (and (string-match server rcirc-server) |
| 2700 | (string-match nick rcirc-nick)) | 2704 | (string-match nick rcirc-nick)) |
| 2701 | (cond ((equal method 'nickserv) | 2705 | (cond ((equal method 'nickserv) |
| 2702 | (rcirc-send-string | 2706 | (rcirc-send-privmsg |
| 2703 | process | 2707 | process |
| 2704 | (concat "PRIVMSG " (or (cadr args) "nickserv") | 2708 | (or (cadr args) "NickServ") |
| 2705 | " :identify " (car args)))) | 2709 | (concat "identify " (car args)))) |
| 2706 | ((equal method 'chanserv) | 2710 | ((equal method 'chanserv) |
| 2707 | (rcirc-send-string | 2711 | (rcirc-send-privmsg |
| 2708 | process | 2712 | process |
| 2709 | (concat | 2713 | "ChanServ" |
| 2710 | "PRIVMSG chanserv :identify " | 2714 | (format "identify %s %s" (car args) (cadr args)))) |
| 2711 | (car args) " " (cadr args)))) | ||
| 2712 | ((equal method 'bitlbee) | 2715 | ((equal method 'bitlbee) |
| 2713 | (rcirc-send-string | 2716 | (rcirc-send-privmsg |
| 2714 | process | 2717 | process |
| 2715 | (concat "PRIVMSG &bitlbee :identify " (car args)))) | 2718 | "&bitlbee" |
| 2719 | (concat "identify " (car args)))) | ||
| 2716 | (t | 2720 | (t |
| 2717 | (message "No %S authentication method defined" | 2721 | (message "No %S authentication method defined" |
| 2718 | method)))))))) | 2722 | method)))))))) |