RFC: BAN and UNBAN commands

Corwin Brust <[email protected]>
Newsgroups gmane.emacs.erc.general
Message-ID <CAJf-WoQgMa_44nzOTDPYxPfBrDKiE3no0t=caoZhVcNuD=M5pA@mail.gmail.com>
I created a function and ERC commands for BAN and UNBAN.   They rely on the
built-in OP and DEOP commands (which in turn rely on CHANNELSERV) when you
use them without already having OP status (+o) in the given channel.

I hope they might be useful to others -of course; eventually- but
especially, I gratefully anticipate any feedback you think may improve my
knowledge of ERC, elisp, or give me a better sense of the stylistic
preferences of other users.

TIA for your comments and suggestions.
Corwin

https://git.sr.ht/~mplscorwin/dotfiles/tree/master/item/elisp/init-erc-30.el#L161

(defun erc-channel-ban-user (who &optional unban)  "Attempt to set
mode +b for WHO in the current channel.
WHO is a string containing the nick of the user to ban.  WhenUNBAN is
non-nil, attemp to remove channel ban, instead.  UseCHANNELSERV to
attempt to gain OP in the current channel, ifnecessary, in which case
drop OP again afterword.
Return a string indicicating the outcome."  (if-let ((channel
(erc-default-target))	   (mynick (erc-current-nick)))      (let ((isop
(if-let ((user (erc-get-channel-user mynick)))		
(erc-channel-user-op (cdr user)))))	(unless isop (erc-cmd-OPME))	(if
(prog1 (erc-server-send (format "MODE %s %sb %s :"					
channel					    (if unban "-" "+")					    who))	      (unless isop
(erc-cmd-DEOPME)))	    (format "Banned %s from %s" who channel)	
(format "Failed to band %s from %s" who channel)))    "Not an IRC
channel or missing WHO, a nickname to ban"))
(defun erc-cmd-BAN (who)  "Attempt to set mode +b for WHO in the
current channel."  (erc-display-line (erc-channel-ban-user who)))
(defun erc-cmd-UNBAN (who)  "Attempt to set mode -b for WHO in the
current channel."  (erc-display-line (erc-channel-ban-user who t)))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.