rcircOperator

Here are some useful commands for your init file if you use rcirc and you’re an operator.

The /op and /deop commands are specific to Freenode’s irc server, I think. They tell ChanServ to op you instead of using the /mode command.

;; rcirc /op

(eval-after-load 'rcirc
  '(defun-rcirc-command op (input)
     "Op myself on the current channel."
     (interactive "s")
     (rcirc-send-message process "chanserv"
			 (concat "op " target))))

;; rcirc /deop

(eval-after-load 'rcirc
  '(defun-rcirc-command deop (input)
     "Deop myself on the current channel."
     (interactive "s")
     (rcirc-send-message process "chanserv"
			 (concat "deop " target))))

;; rcirc /mute

(eval-after-load 'rcirc
  '(defun-rcirc-command mute (input)
     "Mute nick"
     (interactive "s")
     (rcirc-send-string process (format "MODE %s +q %s!*@*"
					target input))))

;; rcirc /unmute

(eval-after-load 'rcirc
  '(defun-rcirc-command unmute (input)
     "Mute nick"
     (interactive "s")
     (rcirc-send-string process (format "MODE %s -q %s!*@*"
					target input))))

;; rcirc /ban

(eval-after-load 'rcirc
  '(defun-rcirc-command ban (input)
     "Mute nick"
     (interactive "s")
     (rcirc-send-string process (format "MODE %s +b %s!*@*"
					target input))))

;; rcirc /unban

(eval-after-load 'rcirc
  '(defun-rcirc-command unban (input)
     "Mute nick"
     (interactive "s")
     (rcirc-send-string process (format "MODE %s -b %s!*@*"
					target input))))

;; rcirc /kickban

(eval-after-load 'rcirc
  '(defun-rcirc-command kickban (input)
     "Mute nick"
     (interactive "s")
     (rcirc-send-string process (format "MODE %s +b %s!*@*"
					target input))
     (rcirc-send-string process (format "KICK %s %s kickban!"
					target input))))

/op and /opme, /deop and /deopme

Here’s an alternate implementation where /op doesn’t just request operator status for yourself but where /op grants operator status to someone and /opme does this for yourself.

(defun-rcirc-command op (nicks)
  "Send OP for `nicks'.
Limitation: in its interactive form, you can only op one nick."
  (interactive (list (completing-read "Op nick: "
				      (with-rcirc-server-buffer rcirc-nick-table))))
  (dolist (nick (split-string nicks " "))
    (rcirc-send-string process
		       (format "ChanServ OP %s %s" target nick))))

(defalias 'rcirc-cmd-opme
  '(lambda (&optional args process target)
     (interactive)
     (rcirc-cmd-op rcirc-nick))
  "Request a ChanServ OP on my current nick in the current channel.")

(defalias 'rcirc-cmd-deop
  '(lambda (nicks &optional process target)
     (interactive (list (completing-read "De-op nick: "
					 (with-rcirc-server-buffer rcirc-nick-table))))
     (let ((nicks (concat "-" (mapconcat 'identity (split-string
						    nicks) " -"))))
       (rcirc-cmd-op nicks)))
  "Send DE-OP for `nicks'.
Limitation: in its interactive form, you can only de-op one nick.")


(defalias 'rcirc-cmd-deopme
  '(lambda (&optional args process target)
     (interactive)
     (rcirc-cmd-deop rcirc-nick)))

Suggested keybindings:

(define-key rcirc-mode-map (kbd "C-c C-O") 'rcirc-cmd-op)
(define-key rcirc-mode-map (kbd "C-c C-o") 'rcirc-cmd-opme)
(define-key rcirc-mode-map (kbd "C-c C-d") 'rcirc-cmd-deopme)
(define-key rcirc-mode-map (kbd "C-c C-D") 'rcirc-cmd-deop)