+ (let ((ctx (cond
+ ((not params) (murk-current-context))
+ ((seq-contains (car params) "@") (murk-string->context (car params)))
+ (t (list (murk-context-network (murk-current-context)) (car params))))))
+ (let ((network (murk-context-network ctx))
+ (channel (murk-context-channel ctx)))
+ (if channel
+ (murk-send-msg network (murk-msg nil nil "PART" channel))
+ (murk-display-error "Specify which channel to leave")))))
+
+(defun murk-command-switch-context (params)
+ (if (not params)
+ (murk-display-notice nil "Usage: /switchcontext #channel@network")
+ (let ((ctx (murk-string->context (car params))))
+ (murk-switch-to-context ctx)
+ (murk-highlight-current-context)
+ (murk-render-prompt)
+ (if murk-zoomed
+ (murk-zoom-in (murk-current-context))))))
+
+(defun murk-command-nick (params)
+ (if params
+ (let ((new-nick (string-join params " "))
+ (ctx (murk-current-context)))
+ (if ctx
+ (murk-send-msg (murk-context-network ctx)
+ (murk-msg nil nil "NICK" new-nick))
+ (murk-display-error "No current connection")))
+ (murk-display-notice nil "Usage: /nick <new-nick>")))
+
+(defun murk-command-list (params)
+ (let ((ctx (murk-current-context)))
+ (if ctx
+ (if (not params)
+ (murk-display-notice nil "This command can generate lots of output."
+ " Use `/LIST -yes' if you really want this,"
+ " or `/LIST <channel_regexp>' to reduce the output.")
+ (let ((network (murk-context-network ctx)))
+ (if (equal (upcase (car params)) "-YES")
+ (murk-send-msg network (murk-msg nil nil "LIST"))
+ (murk-send-msg network (murk-msg nil nil "LIST"
+ (car params))))))
+ (murk-display-error "No current connection"))))
+
+(defun murk-command-topic (params)
+ (let ((ctx (murk-current-context)))
+ (if (and ctx (not (murk-network-context-p ctx)))
+ (let ((network (murk-context-network ctx))
+ (channel (murk-context-channel ctx)))
+ (if params
+ (murk-send-msg network
+ (murk-msg nil nil "TOPIC" channel
+ (string-join params " ")))
+ (murk-send-msg network
+ (murk-msg nil nil "TOPIC" channel))))
+ (murk-display-notice nil "No current channel."))))
+
+(defun murk-command-msg (params)
+ (let ((network (murk-context-network (murk-current-context))))
+ (if (and params (>= (length params) 2))
+ (let ((to (car params))
+ (text (string-join (cdr params) " ")))
+ (murk-send-msg network (murk-msg nil nil "PRIVMSG" to text))
+ (murk-display-message network
+ (murk-connection-nick network)
+ to text))
+ (murk-display-notice nil "Usage: /msg <nick> <message>"))))
+
+(defun murk-command-me (params)
+ (let* ((ctx (murk-current-context))
+ (network (murk-context-network ctx)))
+ (if (and ctx (not (murk-network-context-p ctx)))
+ (if params
+ (let* ((channel (murk-context-channel ctx))
+ (my-nick (murk-connection-nick network))
+ (action (string-join params " "))
+ (ctcp-text (concat "\01ACTION " action "\01")))
+ (murk-send-msg network
+ (murk-msg nil nil "PRIVMSG"
+ (list channel ctcp-text)))
+ (murk-display-action network my-nick channel action))
+ (murk-display-notice nil "Usage: /me <action>"))
+ (murk-display-notice nil "No current channel."))))
+
+(defun murk-command-version (params)
+ (let ((ctx (murk-current-context)))
+ (if ctx
+ (if params
+ (let ((network (murk-context-network ctx))
+ (nick (car params)))
+ (murk-send-msg network
+ (murk-msg nil nil "PRIVMSG"
+ (list nick "\01VERSION\01")))
+ (murk-display-notice ctx "CTCP version request sent to "
+ nick " on " network))
+ (murk-display-notice ctx "Usage: /version <nick>"))
+ (murk-display-notice nil "No current channel."))))
+
+(defun murk-command-users (_params)
+ (let ((ctx (murk-current-context)))
+ (if (and ctx (not (murk-network-context-p ctx)))
+ (let ((channel (murk-context-channel ctx))
+ (network (murk-context-network ctx))
+ (users (murk-get-context-users ctx)))
+ (murk-display-notice ctx "Users in " channel " on " network ":")
+ (murk-display-notice ctx (string-join users " ")))
+ (murk-display-notice nil "No current channel."))))