"If non-nil, use buffer header to display current host and channel."
:type '(boolean))
+(defcustom murk-autoreply-table nil
+ "Table of autoreply messages.
+
+Each autoreply is a list of two elements: (matcher reply)
+
+Here matcher is a list:
+
+(network src cmd params ...)
+
+and reply is another list:
+
+ (cmd params ...)
+
+Each entry in the matcher list is a regular expression tested against the
+corresponding values in the incomming message. Entries can be nil,
+in which case they match anything."
+ :type '(list (list) (list)))
+
;;; Faces
;;
(if murk-debug
(murk-display-string nil nil string))
(let* ((msg (murk-string->msg string)))
+ (murk-process-autoreplies server msg)
(pcase (murk-msg-cmd msg)
("PING"
(murk-send-msg server
(murk-display-notice (murk-get-context server)
(murk-msg->string msg))))))
+
+;;; User-defined responses
+;;
+
+(defun murk--lists-equal (l1 l2)
+ (if (and l1 l2)
+ (if (or (not (and (car l1) (car l2)))
+ (string-match (car l1) (car l2)))
+ (murk--lists-equal (cdr l1) (cdr l2))
+ nil)
+ t))
+
+(defun murk-process-autoreply (server msg autoreply)
+ (let ((matcher (car autoreply))
+ (reply (cadr autoreply)))
+ (let ((target-server (car matcher)))
+ (when (and (or (not target-server)
+ (and (equal server target-server)))
+ (murk--lists-equal (cdr matcher)
+ (append (list (lurk-msg-src msg)
+ (lurk-msg-cmd msg))
+ (murk-msg-params msg))))
+ (murk-send-msg server
+ (murk-msg nil nil (car reply) (cdr reply)))))))
+
+(defun murk-process-autoreplies (server msg)
+ (mapc
+ (lambda (autoreply)
+ (murk-process-autoreply server msg autoreply))
+ murk-autoreply-table))
+
+
;;; Commands
;;
(defun murk-command-quit (params)
(let ((ctx (murk-current-context)))
(if (not ctx)
- (murk-display-error "No current context")
+ (murk-display-error "No current server")
(let ((quit-msg (if params (string-join params " ") murk-default-quit-msg)))
(murk-send-msg
(murk-context-server ctx)