From 1f57d5c028e295e732927c268de80daf2f8f0cae Mon Sep 17 00:00:00 2001 From: plugd Date: Sun, 18 Jul 2021 21:17:57 +0200 Subject: [PATCH] Fixed bug where /names causes heaps of channels to be added. --- lurk.el | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lurk.el b/lurk.el index fb0178c..f030555 100644 --- a/lurk.el +++ b/lurk.el @@ -271,10 +271,13 @@ portion of the source component of the message, as LURK doesn't use this.") (defun lurk-get-context-users (name) (gethash name lurk-contexts)) +(defun lurk-context-known-p (name) + (not (eq (gethash name lurk-contexts 0) 0))) + (defun lurk-add-context-users (context users) (puthash context - (append users - (gethash context lurk-contexts)) + (cl-union users + (gethash context lurk-contexts)) lurk-contexts)) (defun lurk-del-context-user (context user) @@ -635,15 +638,19 @@ portion of the source component of the message, as LURK doesn't use this.") (let* ((params (lurk-msg-params msg)) (channel (elt params 2)) (names (split-string (elt params 3)))) - (lurk-add-context-users channel names))) + (if (lurk-context-known-p channel) + (lurk-add-context-users channel names) + (lurk-display-notice nil "Users in " channel ": " (string-join names " "))))) ("366" ; ENDOFNAMES (let* ((params (lurk-msg-params msg)) (channel (elt params 1))) - (lurk-display-notice - channel - (lurk--as-string (length (lurk-get-context-users channel))) - " users in " channel))) + (if (lurk-context-known-p channel) + (lurk-display-notice + channel + (lurk--as-string (length (lurk-get-context-users channel))) + " users in " channel) + (lurk-display-notice nil "End of " channel " names list.")))) ("331" (let* ((params (lurk-msg-params msg)) -- 2.20.1