Function: rcirc-markup-bridge-bots

rcirc-markup-bridge-bots is a byte-compiled function defined in rcirc.el.gz.

Signature

(rcirc-markup-bridge-bots SENDER RESPONSE)

Documentation

Detect and reformat bridged messages to appear more natural.

The user option rcirc-bridge-bot-alist specified what SENDER to handle. This function only operates on direct messages (as indicated by RESPONSE).

Source Code

;; Defined in /usr/src/emacs/lisp/net/rcirc.el.gz
(defun rcirc-markup-bridge-bots (sender response)
  "Detect and reformat bridged messages to appear more natural.
The user option `rcirc-bridge-bot-alist' specified what SENDER to
handle.  This function only operates on direct messages (as
indicated by RESPONSE)."
  (catch 'quit
    (atomic-change-group
      (save-match-data
        (when-let* (((string= response "PRIVMSG"))
                    (regexp (alist-get sender rcirc-bridge-bot-alist
                                       nil nil #'string=))
                    ((search-forward-regexp regexp nil t))
                    (nick (match-string-no-properties 1)))
          (replace-match "")            ;delete the bot string
          (unless (member nick rcirc-pseudo-nicks)
            (push nick rcirc-pseudo-nicks))
          (goto-char (point-min))
          (let ((fmt (alist-get "PRIVMSG" rcirc-response-formats
                                nil nil #'string=))
                (hl-face (cond ((member sender rcirc-bright-nicks)
                                'rcirc-bright-nick)
                               ((member sender rcirc-dim-nicks)
                                'rcirc-dim-nick)
                               (t 'rcirc-other-nick)))
                hl-username-p)
            (when (string-match (rx (* "%%") "%" (group (or ?N ?n))) fmt)
              (when (string= (match-string 1 fmt) "N")
                (setq hl-username-p t))
              (search-forward-regexp
               (format-spec
                (alist-get "PRIVMSG" rcirc-response-formats
                           nil nil #'string=)
                `((?m . "") (?r . "") (?t . "") (?f . "")
                  (?N . ,(rx (group (+? nonl))))
                  (?n . ,(rx (group (+? nonl))))))
               nil t)
              (replace-match
               (propertize
                nick
                'help-echo (format "Message bridged via %s" sender)
                'face `(,@(and hl-username-p (list hl-face))
                        rcirc-bridged-nick))
               nil t nil 1))))))))