(concat (murk-context-name ctx) "@"
(murk-context-server ctx))))
+(defun murk-get-context (server &optional name)
+ (if name
+ (assoc server murk-contexts)
+ (let ((test-ctx (list server name)))
+ (seq-find (lambda (ctx)
+ (equal (seq-take ctx 2) test-ctx))
+ murk-contexts))))
;;; Buffer
;;
'invisible context-atom)))))))
(murk-scroll-windows-to-last-line))
+(defun murk-display-message (server from to text)
+ (let ((context (if (string-prefix-p "#" to)
+ (murk-get-context server to)
+ (murk-get-context server))))
+ (murk-display-string
+ context
+ (if (murk-server-context-p context)
+ (concat "[" from " -> " to "]")
+ (concat (murk-context->string context) " <" from ">"))
+ text)))
+
(defun murk-display-notice (context &rest notices)
(murk-display-string
context
(if murk-show-joins
(murk-display-notice nil nick " quit: " reason))))
+ ("PRIVMSG"
+ (let* ((from (murk-msg-src msg))
+ (params (murk-msg-params msg))
+ (to (car params))
+ (text (cadr params)))
+ (pcase text
+ ("\01VERSION\01"
+ (let ((version-string (concat murk-version " - running on GNU Emacs " emacs-version)))
+ (murk-send-msg server
+ (murk-msg nil nil "NOTICE"
+ (list from (concat "\01VERSION "
+ version-string
+ "\01")))))
+ (murk-display-notice nil "CTCP version request received from "
+ from " on " server))
+
+ ((rx (let ping (: "\01PING " (* (not "\01")) "\01")))
+ (murk-send-msg server (lurk-msg nil nil "NOTICE" (list from ping)))
+ (murk-display-notice nil "CTCP ping received from " from " on " server))
+
+ ("\01USERINFO\01"
+ (murk-display-notice nil "CTCP userinfo request from " from
+ " on " server " (no response sent)"))
+
+ ("\01CLIENTINFO\01"
+ (murk-display-notice nil "CTCP clientinfo request from " from
+ " on " server " (no response sent)"))
+
+ ((rx (: "\01ACTION " (let action-text (* (not "\01"))) "\01"))
+ (murk-display-action from to action-text))
+
+ (_
+ (murk-display-message server from to text)))))
+
(_
(murk-display-notice nil (murk-msg->string msg))))))
(murk-send-msg server (murk-msg nil nil "PART" channel))
(murk-display-error "No current channel to leave."))))
+(defun murk-command-msg (params)
+ (let ((server (murk-context-server (murk-current-context))))
+ (if (and params (>= (length params) 2))
+ (let ((to (car params))
+ (text (string-join (cdr params) " ")))
+ (murk-send-msg server (lurk-msg nil nil "PRIVMSG" to text))
+ (murk-display-message server
+ (murk-connection-nick server)
+ to text))
+ (murk-display-notice nil "Usage: /msg <nick> <message>"))))
;;; Command entering
;;
(murk-display-error "Badly formed command.")))
(unless (string-empty-p string)
(if (murk-current-context)
- (progn
+ (let ((server (murk-context-server (murk-current-context))))
(murk-send-msg server
(murk-msg nil nil "PRIVMSG"
- (murk-context-name murk-current-context)
+ (murk-context-name (murk-current-context))
string))
- (murk-display-message murk-nick (murk-context->string (murk-current-context)) string))
+ (murk-display-message server
+ murk-nick
+ (murk-context->string (murk-current-context))
+ string))
(murk-display-error "No current context.")))))