+(defun lurk-command-debug (params)
+ (setq lurk-debug
+ (if params
+ (if (equal (upcase (car params)) "ON")
+ t
+ nil)
+ (not lurk-debug)))
+ (lurk-display-notice nil "Debug mode now " (if lurk-debug "on" "off") "."))
+
+(defun lurk-command-header (params)
+ (if
+ (if params
+ (equal (upcase (car params)) "ON")
+ (not header-line-format))
+ (progn
+ (lurk-setup-header)
+ (lurk-display-notice nil "Header enabled."))
+ (setq-local header-line-format nil)
+ (lurk-display-notice nil "Header disabled.")))
+
+(defun lurk-command-connect (params)
+ (if params
+ (let ((network (car params)))
+ (lurk-display-notice nil "Attempting to connect to " network "...")
+ (lurk-connect network))
+ (lurk-display-notice nil "Usage: /connect <network>")))
+
+(defun lurk-command-quit (params)
+ (let ((quit-msg (if params (string-join params " ") nil)))
+ (lurk-send-msg (lurk-msg nil nil "QUIT" quit-msg))))
+
+(defun lurk-command-part (params)
+ (let ((channel (if params (car params) lurk-current-context)))
+ (if channel
+ (lurk-send-msg (lurk-msg nil nil "PART" channel))
+ (lurk-display-error "No current channel to leave."))))
+
+(defun lurk-command-version (params)
+ (if params
+ (let ((nick (car params)))
+ (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
+ (list nick "\01VERSION\01")))
+ (lurk-display-notice nil "CTCP version request sent to " nick))
+ (lurk-display-notice nil "Usage: /version <nick>")))
+
+(defun lurk-command-quit (params)
+ (let ((quit-msg (if params (string-join parms " ") lurk-default-quit-msg)))
+ (lurk-send-msg (lurk-msg nil nil "QUIT" quit-msg))))
+
+(defun lurk-command-nick (params)
+ (let ((new-nick (if params (string-join params " ") nil)))
+ (if new-nick
+ (if (lurk-connected-p)
+ (lurk-send-msg (lurk-msg nil nil "NICK" new-nick))
+ (setq lurk-nick nick)
+ (lurk-display-notice nil "Set default nick to '" nick "'."))
+ (lurk-display-notice nil "Current nick: " lurk-nick))))
+
+(defun lurk-command-me (params)
+ (if lurk-current-context
+ (if params
+ (let* ((action (string-join params " "))
+ (ctcp-text (concat "\01ACTION " action "\01")))
+ (lurk-send-msg (lurk-msg nil nil "PRIVMSG"
+ (list lurk-current-context ctcp-text)))
+ (lurk-display-action lurk-nick lurk-current-context action))
+ (lurk-display-notice nil "Usage: /me <action>"))
+ (lurk-display-notice nil "No current channel.")))
+
+(defun lurk-command-list (params)
+ (if (not params)
+ (lurk-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.")
+ (if (equal (upcase (car params)) "-YES")
+ (lurk-send-msg (lurk-msg nil nil "LIST"))
+ (lurk-send-msg (lurk-msg nil nil "LIST" (car params))))))
+
+(defun lurk-command-topic (params)
+ (if lurk-current-context
+ (if params
+ (lurk-send-msg (lurk-msg nil nil "TOPIC" lurk-current-context (string-join params " ")))
+ (lurk-display-notice nil "Usage: /topic <new topic>"))
+ (lurk-display-notice nil "No current channel.")))
+
+(defun lurk-command-msg (params)
+ (if (and params (>= 2 (length params)))
+ (let ((to (car params))
+ (text (string-join (cdr params) " ")))
+ (lurk-send-msg (lurk-msg nil nil "PRIVMSG" to text))
+ (lurk-display-message lurk-nick to text))
+ (lurk-display-notice nil "Usage: /msg <nick> <message>")))
+
+(defvar lurk-history nil
+ "Commands and messages sent in current session.")
+
+