(defvar *sh-nicks* (make-hash-table :test 'equal))
(defvar *sh-channel* "#ubuntu-cn")
(defvar *sh-nicks-file* "~/.lisp/say-hello.nicks")
(defun say-hello ()
(goto-char (point-min))
(when (and (string= (buffer-name) *sh-channel*)
(ignore-errors (re-search-forward "^*** \([^(]+\) (~?\([^@]+\)@ .*joined" nil t)))
(let ((str (gethash (match-string-no-properties 2) *sh-nicks*)))
(when str
(erc-send-message (concat (match-string-no-properties 1) ": " str))))))
(defun say-hello-build-nick-list ()
(with-temp-buffer
(clrhash *sh-nicks*)
(insert-file-contents *sh-nicks-file* nil nil nil t)
(while (re-search-forward "\([^[:space:]]+\)[[:space:]]+\([^[:space:]]+\)" nil t)
(puthash (match-string-no-properties 1) (match-string-no-properties 2) *sh-nicks*))))
(say-hello-build-nick-list)
;; *** blez (blez@ip-162-4-71-77.varnalan.net) has joined channel #ubuntu
(add-hook 'erc-insert-post-hook 'say-hello)
;; (remove-hook 'erc-insert-post-hook 'auto-hello)
-