|
|
@@ -47,6 +47,11 @@
|
|
|
(preprocess-input (subseq text 11))
|
|
|
(replace-all text "@chatikbot" "ты")))))
|
|
|
|
|
|
+(defun parse-cmd (text)
|
|
|
+ (let* ((args (split-sequence:split-sequence #\Space (subseq text 1) :remove-empty-subseqs t))
|
|
|
+ (cmd (subseq (car args) 0 (position #\@ (car args)))))
|
|
|
+ (values (intern (string-upcase cmd) "KEYWORD") (rest args))))
|
|
|
+
|
|
|
(defun handle-message (message)
|
|
|
(let ((id (aget "message_id" message))
|
|
|
(chat-id (aget "id" (aget "chat" message)))
|
|
|
@@ -56,12 +61,7 @@
|
|
|
(log:info "handle-message" message)
|
|
|
(when text
|
|
|
(if (equal #\/ (char text 0))
|
|
|
- (let ((cmd (intern (string-upcase
|
|
|
- (subseq text 1 (position #\Space text)))
|
|
|
- "KEYWORD"))
|
|
|
- (args (when (position #\Space text)
|
|
|
- (split-sequence:split-sequence
|
|
|
- #\Space (subseq text (1+ (position #\Space text)))))))
|
|
|
+ (multiple-value-bind (cmd args) (parse-cmd text)
|
|
|
(case cmd
|
|
|
(:postakb (handle-cmd-post-akb chat-id id args))
|
|
|
(:akb (handle-cmd-akb chat-id id args))
|