Paste number 712: autoreply

Paste number 712: autoreply
Pasted by: bojohan
When:13 years, 8 months ago
Share:Tweet this! | http://paste.lisp.org/+JS
Channel:#emacs
Paste contents:
Raw Source | XML | Display As
(defconst my-erc-autoreply-in-progress  nil)
(defvar   my-erc-autoreply-futurama-count 5)
(defvar   my-erc-autoreply-aa-count     0)
(defun my-erc-autoreply ()
  (when (not my-erc-autoreply-in-progress)
    (let ((my-erc-autoreply-in-progress t))
      (when (and (member (buffer-name) '("#emacs" "#gnus"))
		 (string-match "<\\([^\n>]*\\)>\\s-*\\(.*\\)" string)
		 (not (member (match-string 1 string) ; nick
			      (list erc-nick "fsbot"))))
	(let* ((s1 (match-string-no-properties 1 string)) ; nick
	       (s2 (match-string-no-properties 2 string)) ; line
	       (s (cond
		   ((string-match "\\<\\(bender\\|fry\\|futurama\\)\\>" s2)
		    (when (wholenump my-erc-autoreply-futurama-count)
		      (decf my-erc-autoreply-futurama-count)
		      (substring (shell-command-to-string
				  "HEAD slashdot.org | g 'X-\\(Bender\\|Fry\\)'")
				 2)))
		   ((and (string-match "\\<aa\\>\\|\\<anti[- ]?alias" s2)
			 (not (string-match "\\<cells?\\>\\|\\<batter" s2)))
		    (when (wholenump my-erc-autoreply-aa-count)
		      (decf my-erc-autoreply-aa-count)
		      "arrgh! my eyes! my eyes!")))))
	  (when s
	    (erc-send-message s)))))))

(add-hook 'erc-insert-post-hook 'my-erc-autoreply)

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.