;;; -*- lexical-binding: t -*- (require 'doctor) (require 'rcirc) (defun besuch-beim-artz (&rest args) "Start IRC bot to interface doc" (setq rcirc-markup-text-functions nil) (let* ((rcirc-server-alist (list args)) (buf (generate-new-buffer "*artz-besuch*")) (nick (plist-get (cdr args) :nick)) (chan (car (plist-get (cdr args) :channels))) (hook (lambda (proc sender response target text) (when (and (not (string= sender nick)) (string= response "PRIVMSG") (string-match-p (concat "^" nick ":") text)) (with-current-buffer buf (insert (replace-regexp-in-string (concat "^" nick ": *") "" text)) (doctor-read-print) (save-excursion (forward-line -2) (let* ((raw (thing-at-point 'line t)) (response (replace-regexp-in-string "[ \t\n]*\\'" "" raw)) (rcirc-target chan) (rcirc-server-buffer (get-buffer (car args)))) (rcirc-send-message proc target response)))))))) (add-hook 'rcirc-print-functions hook) (with-current-buffer buf (doctor-mode)) (rcirc nil))) ;;; example: ;; (besuch-beim-artz "irc.fau.de" ;; :nick "azile" ;; :channels '("#faui2k19"))