[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-commit] [COMMIT] erc-dcc: Fix some issues with erc-dcc-do-CLOSE-com
From: |
Michael Olson |
Subject: |
[Erc-commit] [COMMIT] erc-dcc: Fix some issues with erc-dcc-do-CLOSE-command. |
Date: |
Tue, 30 Sep 2008 23:25:49 -0700 |
* erc-dcc.el (erc-dcc-do-CLOSE-command): Update docstring. Don't use the
line variable. Try to disambiguate between type and nick when only one
is provided. Validate both type and nick arguments. Allow matching by
just nick.
---
erc-dcc.el | 43 ++++++++++++++++++++++++++++++-------------
1 files changed, 30 insertions(+), 13 deletions(-)
diff --git a/erc-dcc.el b/erc-dcc.el
index cbd02d0..4d2fcd3 100644
--- a/erc-dcc.el
+++ b/erc-dcc.el
@@ -79,6 +79,11 @@ IRC users."
:group 'erc-dcc
:type 'boolean)
+(defconst erc-dcc-connection-types
+ '("CHAT" "GET" "SEND")
+ "List of valid DCC connection types.
+All values of the list must be uppercase strings.")
+
(defvar erc-dcc-list nil
"List of DCC connections. Looks like:
((:nick \"address@hidden" :type GET :peer proc :parent proc :size size :file
file)
@@ -477,19 +482,31 @@ where FOO is one of CLOSE, GET, SEND, LIST, CHAT, etc."
t))))
(defun erc-dcc-do-CLOSE-command (proc &optional type nick)
- "/dcc close type nick
-type and nick are optional."
- ;; FIXME, should also work if only nick is specified
- (when (string-match (concat "^\\s-*\\(\\S-+\\)? *\\("
- erc-valid-nick-regexp "\\)?\\s-*$") line)
- (let ((type (when (match-string 1 line)
- (intern (upcase (match-string 1 line)))))
- (nick (match-string 2 line))
- (ret t))
+ "Close a connection. Usage: /dcc close type nick.
+At least one of TYPE and NICK must be provided."
+ ;; disambiguate type and nick if only one is provided
+ (when (and type (null nick)
+ (not (member (upcase type) erc-dcc-connection-types)))
+ (setq nick type)
+ (setq type nil))
+ ;; validate nick argument
+ (unless (and nick (string-match (concat "\\`" erc-valid-nick-regexp "\\'")
+ nick))
+ (setq nick nil))
+ ;; validate type argument
+ (unless (and type (member (upcase type) erc-dcc-connection-types))
+ (setq type nil))
+ (when (or nick type)
+ (let ((ret t))
(while ret
- (if nick
- (setq ret (erc-dcc-member :type type :nick nick))
- (setq ret (erc-dcc-member :type type)))
+ (cond ((and nick type)
+ (setq ret (erc-dcc-member :type type :nick nick)))
+ (nick
+ (setq ret (erc-dcc-member :nick nick)))
+ (type
+ (setq ret (erc-dcc-member :type type)))
+ (t
+ (setq ret nil)))
(when ret
;; found a match - delete process if it exists.
(and (processp (plist-get ret :peer))
@@ -500,7 +517,7 @@ type and nick are optional."
'dcc-closed
?T (plist-get ret :type)
?n (erc-extract-nick (plist-get ret :nick))))))
- t))
+ t))
(defun erc-dcc-do-GET-command (proc nick &rest file)
"Do a DCC GET command. NICK is the person who is sending the file.
--
debian.1.5.6.1.19.ge6b2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-commit] [COMMIT] erc-dcc: Fix some issues with erc-dcc-do-CLOSE-command.,
Michael Olson <=