Browse Source

add default group for group controls

Vyacheslav Shebanov 5 năm trước cách đây
mục cha
commit
8b35260a1c
1 tập tin đã thay đổi với 7 bổ sung2 xóa
  1. 7 2
      plugins/massmention.lisp

+ 7 - 2
plugins/massmention.lisp

@@ -17,6 +17,11 @@
 (defun remove-user-from-group (group mentions)
   (apply-to-mentions group mentions #'db/remove-user-from-group "Удалил ~{~a~^,~} из группы ~a."))
 
+(defun apply-contol-function (args func)
+  (cond
+    ((equalp (subseq (second args) 0 1) "@") (funcall func +default-group+ (cdr *args*)))
+    (:otherwise (funcall func (second args) (subseq *args* 2)))))
+
 (defun apply-to-mentions (group mentions func message)
   (handler-case (progn
                  (loop for name in mentions
@@ -39,6 +44,6 @@
 (def-message-cmd-handler handle-cmd-all (:all)
   (cond
     ((= 1 (length *args*)) (handle-mass-mention (car *args*)))
-    ((equalp "add" (car *args*)) (add-user-to-group (second *args*) (subseq *args* 2)))
-    ((equalp "remove" (car *args*)) (remove-user-from-group (second *args*) (subseq *args* 2)))
+    ((equalp "add" (car *args*)) (apply-contol-function *args* #'add-user-to-group))
+    ((equalp "remove" (car *args*)) (apply-contol-function *args* #'remove-user-from-group))
     (:otherwise (handle-mass-mention +default-group+))))