Jelajahi Sumber

Use 'from.id' for admin cmd authorization

Innokenty Enikeev 9 tahun lalu
induk
melakukan
6264328610
1 mengubah file dengan 4 tambahan dan 3 penghapusan
  1. 4 3
      chatikbot.lisp

+ 4 - 3
chatikbot.lisp

@@ -55,6 +55,7 @@
 
 (defun handle-message (message)
   (let ((id (aget "message_id" message))
+        (from-id (aget "id" (aget "from" message)))
         (chat-id (aget "id" (aget "chat" message)))
         (text (aget "text" message))
         (location (aget "location" message))
@@ -79,7 +80,7 @@
               (:lastrss (handle-cmd-last-rss chat-id id args))
               (:wall (handle-cmd-wall chat-id id args))
               (:nalunch (handle-cmd-nalunch chat-id id args))
-              (otherwise (handle-admin-cmd chat-id text cmd args))))
+              (otherwise (handle-admin-cmd from-id chat-id text cmd args))))
           (send-dont-understand chat-id (preprocess-input text))))
     (when location
       (push (cons chat-id location) *chat-locations*)
@@ -109,8 +110,8 @@
           (format t "~{~S~^ ;~%     ~}~%"
                   (multiple-value-list (eval (read-from-string input)))))))))
 
-(defun handle-admin-cmd (chat-id text cmd args)
-  (if (find chat-id *admins*)
+(defun handle-admin-cmd (from-id chat-id text cmd args)
+  (if (find from-id *admins*)
       (case cmd
         (:eval (telegram-send-message chat-id (rep (format nil "~{~A~^ ~}" args))))
         (otherwise (send-dont-understand chat-id (preprocess-input (subseq text 1)))))