If you just want to retrieve the mode of a channel, you don't have to pass a mode argument at all, and you'll get a RPL_CHANNELMODEIS in return.
Signed-off-by: Julien Danjou julien@danjou.info --- command.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/command.lisp b/command.lisp index aac445b..c167561 100644 --- a/command.lisp +++ b/command.lisp @@ -9,7 +9,7 @@ (defgeneric nick (connection new-nickname)) (defgeneric user- (connection username mode &optional realname)) (defgeneric oper (connection name password)) -(defgeneric mode (connection nickname mode)) +(defgeneric mode (connection nickname &optional mode)) (defgeneric op (connection channel nickname)) (defgeneric deop (connection channel nickname)) (defgeneric voice (connection channel user)) @@ -103,7 +103,7 @@ registered." (defmethod oper ((connection connection) (name string) (password string)) (send-irc-message connection :oper name password))
-(defmethod mode ((connection connection) (nickname string) (mode string)) +(defmethod mode ((connection connection) (nickname string) &optional mode) (send-irc-message connection :mode nickname mode))
;; utility functions not part of the RFCs
The mode needs to be added on the channel, not the the target.
Signed-off-by: Julien Danjou julien@danjou.info --- event.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/event.lisp b/event.lisp index eb97fc9..5e6e417 100644 --- a/event.lisp +++ b/event.lisp @@ -289,7 +289,7 @@ objects in sync.")) (op mode-name value) change (unless (has-mode-p channel mode-name) - (add-mode target mode-name + (add-mode channel mode-name (make-mode connection channel mode-name))) (funcall (if (char= #+ op) #'set-mode #'unset-mode) channel mode-name value)))))))
Hi Julien,
Thanks. Committed as r237.
Bye,
Erik.
On Sun, Jan 13, 2013 at 3:04 PM, Julien Danjou julien@danjou.info wrote:
The mode needs to be added on the channel, not the the target.
Signed-off-by: Julien Danjou julien@danjou.info
event.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/event.lisp b/event.lisp index eb97fc9..5e6e417 100644 --- a/event.lisp +++ b/event.lisp @@ -289,7 +289,7 @@ objects in sync.")) (op mode-name value) change (unless (has-mode-p channel mode-name)
(add-mode target mode-name
(add-mode channel mode-name (make-mode connection channel mode-name))) (funcall (if (char= #\+ op) #'set-mode #'unset-mode) channel mode-name value)))))))
-- 1.8.1
cl-irc-devel site list cl-irc-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-irc-devel
The code used into mode-message and rpl_channelmodeis-message is exactly the same, so let's factorize this a bit to less code.
Signed-off-by: Julien Danjou julien@danjou.info --- event.lisp | 34 ++++++---------------------------- package.lisp | 1 + utility.lisp | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/event.lisp b/event.lisp index 5e6e417..57ccf51 100644 --- a/event.lisp +++ b/event.lisp @@ -279,20 +279,9 @@ objects in sync.")) (destructuring-bind (target channel &rest mode-arguments) arguments - (let* ((channel (find-channel connection channel)) - (mode-changes - (when channel - (parse-mode-arguments connection channel mode-arguments - :server-p (user connection))))) - (dolist (change mode-changes) - (destructuring-bind - (op mode-name value) - change - (unless (has-mode-p channel mode-name) - (add-mode channel mode-name - (make-mode connection channel mode-name))) - (funcall (if (char= #+ op) #'set-mode #'unset-mode) - channel mode-name value))))))) + (let ((channel (find-channel connection channel))) + (when channel + (apply-mode-changes connection channel mode-arguments (user connection)))))))
(defmethod default-hook ((message irc-mode-message)) (destructuring-bind @@ -300,20 +289,9 @@ objects in sync.")) (arguments message) (let* ((connection (connection message)) (target (or (find-channel connection target) - (find-user connection target))) - (mode-changes - (when target - (parse-mode-arguments connection target arguments - :server-p (user connection))))) - (dolist (change mode-changes) - (destructuring-bind - (op mode-name value) - change - (unless (has-mode-p target mode-name) - (add-mode target mode-name - (make-mode connection target mode-name))) - (funcall (if (char= #+ op) #'set-mode #'unset-mode) - target mode-name value)))))) + (find-user connection target)))) + (when target + (apply-mode-changes connection target arguments (user connection))))))
(defmethod default-hook ((message irc-nick-message)) (with-slots diff --git a/package.lisp b/package.lisp index c09537a..bd5a480 100644 --- a/package.lisp +++ b/package.lisp @@ -32,6 +32,7 @@ :get-mode :set-mode :unset-mode + :apply-mode-changes :parse-mode-arguments :parse-raw-message :normalize-nickname diff --git a/utility.lisp b/utility.lisp index 12c327c..9894ed0 100644 --- a/utility.lisp +++ b/utility.lisp @@ -493,6 +493,21 @@ It returns a list of mode-description records." (split-sequence:split-sequence #: x)) (split-sequence:split-sequence #, argument)))
+(defun apply-mode-changes (connection target mode-arguments server-p) + (dolist (change (parse-mode-arguments connection target mode-arguments + :server-p server-p)) + (apply-mode-change connection target change))) + +(defun apply-mode-change (connection target change) + (destructuring-bind + (op mode-name value) + change + (unless (has-mode-p target mode-name) + (add-mode target mode-name + (make-mode connection target mode-name))) + (funcall (if (char= #+ op) #'set-mode #'unset-mode) + target mode-name value))) + (defun parse-mode-arguments (connection target arguments &key server-p) "Create a list of mode changes with their arguments for `target' from `mode-string' and `arguments'.
Hi Julien,
Thanks for your contributions so far! This one is committed as r239.
Bye,
Erik.
On Sun, Jan 13, 2013 at 3:04 PM, Julien Danjou julien@danjou.info wrote:
The code used into mode-message and rpl_channelmodeis-message is exactly the same, so let's factorize this a bit to less code.
Signed-off-by: Julien Danjou julien@danjou.info
event.lisp | 34 ++++++---------------------------- package.lisp | 1 + utility.lisp | 15 +++++++++++++++ 3 files changed, 22 insertions(+), 28 deletions(-)
diff --git a/event.lisp b/event.lisp index 5e6e417..57ccf51 100644 --- a/event.lisp +++ b/event.lisp @@ -279,20 +279,9 @@ objects in sync.")) (destructuring-bind (target channel &rest mode-arguments) arguments
- (let* ((channel (find-channel connection channel))
(mode-changes
(when channel
(parse-mode-arguments connection channel mode-arguments
:server-p (user connection)))))
(dolist (change mode-changes)
(destructuring-bind
(op mode-name value)
change
(unless (has-mode-p channel mode-name)
(add-mode channel mode-name
(make-mode connection channel mode-name)))
(funcall (if (char= #\+ op) #'set-mode #'unset-mode)
channel mode-name value)))))))
- (let ((channel (find-channel connection channel)))
(when channel
(apply-mode-changes connection channel mode-arguments (user
connection)))))))
(defmethod default-hook ((message irc-mode-message)) (destructuring-bind @@ -300,20 +289,9 @@ objects in sync.")) (arguments message) (let* ((connection (connection message)) (target (or (find-channel connection target)
(find-user connection target)))
(mode-changes
(when target
(parse-mode-arguments connection target arguments
:server-p (user connection)))))
(dolist (change mode-changes)
(destructuring-bind
(op mode-name value)
change
(unless (has-mode-p target mode-name)
(add-mode target mode-name
(make-mode connection target mode-name)))
(funcall (if (char= #\+ op) #'set-mode #'unset-mode)
target mode-name value))))))
(find-user connection target))))
(when target
(apply-mode-changes connection target arguments (user
connection))))))
(defmethod default-hook ((message irc-nick-message)) (with-slots diff --git a/package.lisp b/package.lisp index c09537a..bd5a480 100644 --- a/package.lisp +++ b/package.lisp @@ -32,6 +32,7 @@ :get-mode :set-mode :unset-mode
:apply-mode-changes :parse-mode-arguments :parse-raw-message :normalize-nickname
diff --git a/utility.lisp b/utility.lisp index 12c327c..9894ed0 100644 --- a/utility.lisp +++ b/utility.lisp @@ -493,6 +493,21 @@ It returns a list of mode-description records." (split-sequence:split-sequence #: x)) (split-sequence:split-sequence #, argument)))
+(defun apply-mode-changes (connection target mode-arguments server-p)
- (dolist (change (parse-mode-arguments connection target mode-arguments
:server-p server-p))
- (apply-mode-change connection target change)))
+(defun apply-mode-change (connection target change)
- (destructuring-bind
(op mode-name value)
change
- (unless (has-mode-p target mode-name)
(add-mode target mode-name
(make-mode connection target mode-name)))
- (funcall (if (char= #+ op) #'set-mode #'unset-mode)
target mode-name value)))
(defun parse-mode-arguments (connection target arguments &key server-p) "Create a list of mode changes with their arguments for `target' from `mode-string' and `arguments'. -- 1.8.1
cl-irc-devel site list cl-irc-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-irc-devel
Signed-off-by: Julien Danjou julien@danjou.info --- package.lisp | 1 - 1 file changed, 1 deletion(-)
diff --git a/package.lisp b/package.lisp index bd5a480..50aa6a7 100644 --- a/package.lisp +++ b/package.lisp @@ -17,7 +17,6 @@ :stop-background-message-handler :destructuring-arguments :&req - :socket-connect :server-name :server-port :no-such-reply
Hi Julien,
Thanks. That was very ancient legacy! (There used to be a function named like that.)
Bye,
Erik.
On Sun, Jan 13, 2013 at 3:04 PM, Julien Danjou julien@danjou.info wrote:
Signed-off-by: Julien Danjou julien@danjou.info
package.lisp | 1 - 1 file changed, 1 deletion(-)
diff --git a/package.lisp b/package.lisp index bd5a480..50aa6a7 100644 --- a/package.lisp +++ b/package.lisp @@ -17,7 +17,6 @@ :stop-background-message-handler :destructuring-arguments :&req
:socket-connect :server-name :server-port :no-such-reply
-- 1.8.1
cl-irc-devel site list cl-irc-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-irc-devel
This is actually unused, so let's remove it.
Signed-off-by: Julien Danjou julien@danjou.info --- command.lisp | 1 - protocol.lisp | 13 ------------- 2 files changed, 14 deletions(-)
diff --git a/command.lisp b/command.lisp index c167561..5b84a60 100644 --- a/command.lisp +++ b/command.lisp @@ -552,7 +552,6 @@ for `connection'.")) (make-dcc-chat-connection :irc-connection irc-connection :remote-user (find-user irc-connection (source message)) - :socket socket :network-stream (usocket:socket-stream socket))))))))
(defmethod dcc-request-accept ((message dcc-ctcp-dcc-chat-request-message)) diff --git a/protocol.lisp b/protocol.lisp index 7d89530..e7caaaa 100644 --- a/protocol.lisp +++ b/protocol.lisp @@ -122,10 +122,6 @@ user class."))) :initarg :server-port :accessor server-port :initform *default-irc-server-port*) - (socket - :initarg :socket - :reader socket - :documentation "Slot to store socket (for internal use only).") (network-stream :initarg :network-stream :accessor network-stream @@ -212,7 +208,6 @@ connection.") (password nil) (server-name "") (server-port nil) - (socket nil) (network-stream nil) (outgoing-external-format *default-outgoing-external-format*) (client-stream t) @@ -226,7 +221,6 @@ connection.") :password password :server-name server-name :server-port server-port - :socket socket :network-stream network-stream :output-stream output-stream :client-stream client-stream))) @@ -461,11 +455,6 @@ a lost connection is detected.") :accessor remote-user :documentation "The user at the other end of this connection. The user at this end can be reached via your normal connection object.") - (socket - :initarg :socket - :accessor socket - :initform nil - :documentation "Socket used to do the remote client.") (network-stream :initarg :network-stream :accessor network-stream) @@ -554,7 +543,6 @@ of the network pipe.") (client-stream nil) (irc-connection nil) (close-on-main t) - (socket nil) (network-stream nil) (outgoing-external-format *default-outgoing-external-format*) (hooks nil)) @@ -569,7 +557,6 @@ of the network pipe.") :output-stream output-stream :irc-connection irc-connection :close-on-main close-on-main - :socket socket :network-stream network-stream))) (dolist (hook hooks) (add-hook connection (car hook) (cdar hook)))
Hi Julien,
Thanks! Committed as r236. You missed a second socket in command.lisp, actually. Removed that as well.
Bye,
Erik.
On Sun, Jan 13, 2013 at 3:04 PM, Julien Danjou julien@danjou.info wrote:
This is actually unused, so let's remove it.
Signed-off-by: Julien Danjou julien@danjou.info
command.lisp | 1 - protocol.lisp | 13 ------------- 2 files changed, 14 deletions(-)
diff --git a/command.lisp b/command.lisp index c167561..5b84a60 100644 --- a/command.lisp +++ b/command.lisp @@ -552,7 +552,6 @@ for `connection'.")) (make-dcc-chat-connection :irc-connection irc-connection :remote-user (find-user irc-connection (source message))
:socket socket :network-stream (usocket:socket-stream socket))))))))
(defmethod dcc-request-accept ((message dcc-ctcp-dcc-chat-request-message)) diff --git a/protocol.lisp b/protocol.lisp index 7d89530..e7caaaa 100644 --- a/protocol.lisp +++ b/protocol.lisp @@ -122,10 +122,6 @@ user class."))) :initarg :server-port :accessor server-port :initform *default-irc-server-port*)
- (socket
- :initarg :socket
- :reader socket
- :documentation "Slot to store socket (for internal use only).") (network-stream :initarg :network-stream :accessor network-stream
@@ -212,7 +208,6 @@ connection.") (password nil) (server-name "") (server-port nil)
(socket nil) (network-stream nil) (outgoing-external-format
*default-outgoing-external-format*) (client-stream t) @@ -226,7 +221,6 @@ connection.") :password password :server-name server-name :server-port server-port
:socket socket :network-stream network-stream :output-stream output-stream :client-stream client-stream)))
@@ -461,11 +455,6 @@ a lost connection is detected.") :accessor remote-user :documentation "The user at the other end of this connection. The user at this end can be reached via your normal connection object.")
- (socket
- :initarg :socket
- :accessor socket
- :initform nil
- :documentation "Socket used to do the remote client.") (network-stream :initarg :network-stream :accessor network-stream)
@@ -554,7 +543,6 @@ of the network pipe.") (client-stream nil) (irc-connection nil) (close-on-main t)
(socket nil) (network-stream nil) (outgoing-external-format
*default-outgoing-external-format*) (hooks nil)) @@ -569,7 +557,6 @@ of the network pipe.") :output-stream output-stream :irc-connection irc-connection :close-on-main close-on-main
(dolist (hook hooks) (add-hook connection (car hook) (cdar hook))):socket socket :network-stream network-stream)))
-- 1.8.1
cl-irc-devel site list cl-irc-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-irc-devel
This allows one to construct its own loop.
Signed-off-by: Julien Danjou julien@danjou.info --- package.lisp | 1 + 1 file changed, 1 insertion(+)
diff --git a/package.lisp b/package.lisp index 50aa6a7..58d65e3 100644 --- a/package.lisp +++ b/package.lisp @@ -12,6 +12,7 @@ (:nicknames :irc) (:export :read-message-loop :read-message + :read-irc-message :irc-message-event :start-background-message-handler :stop-background-message-handler
Committed as r238. Thanks!
Bye,
Erik.
On Sun, Jan 13, 2013 at 3:04 PM, Julien Danjou julien@danjou.info wrote:
If you just want to retrieve the mode of a channel, you don't have to pass a mode argument at all, and you'll get a RPL_CHANNELMODEIS in return.
Signed-off-by: Julien Danjou julien@danjou.info
command.lisp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/command.lisp b/command.lisp index aac445b..c167561 100644 --- a/command.lisp +++ b/command.lisp @@ -9,7 +9,7 @@ (defgeneric nick (connection new-nickname)) (defgeneric user- (connection username mode &optional realname)) (defgeneric oper (connection name password)) -(defgeneric mode (connection nickname mode)) +(defgeneric mode (connection nickname &optional mode)) (defgeneric op (connection channel nickname)) (defgeneric deop (connection channel nickname)) (defgeneric voice (connection channel user)) @@ -103,7 +103,7 @@ registered." (defmethod oper ((connection connection) (name string) (password string)) (send-irc-message connection :oper name password))
-(defmethod mode ((connection connection) (nickname string) (mode string)) +(defmethod mode ((connection connection) (nickname string) &optional mode) (send-irc-message connection :mode nickname mode))
;; utility functions not part of the RFCs
1.8.1
cl-irc-devel site list cl-irc-devel@common-lisp.net http://common-lisp.net/mailman/listinfo/cl-irc-devel