トップ «前の日記(2003-04-18 (Fri)) 最新 次の日記(2003-04-24 (Thu))» 編集

猫熊は燃えつきた?!日記

最近なんにもやっていませんが、なにかやったらこちらに置くようにしています。
2002|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|
2011|09|
2012|02|


2003-04-23 (Wed) ちょっと風邪気味 [長年日記]

飲みすぎ

ぼくは言ったかなぁ?良く覚えていないや。まぁ、ぼくも散々飲んだくれていたから、あんまり人のことは言えないけど、ぼくが飲んだくれていたのは 独身のとき だから、ちょっと違うかな。

新形?Spam

最近、ぼくの H" にまで、中国語(と思われる) Spam が来るようになった。H" なメールは全然使っていないのになぁ。。。。

bogofilter その2

またまた、昼休みの気晴らしに、Mew (ただし ver.3) から bogofilter をいじる elisp を書いてみた。
(defun mew-add-bogo-blacklist (&optional white)
  "Bogofilter の spam list にいれる。C-u で nospam list にいれる。"
  (interactive "P")
  (mew-summary-not-in-queue
   (mew-summary-not-in-draft
    (save-excursion
      (mew-summary-goto-message)
      (let* ((bogo (mew-which-exec "bogofilter"))
	     (fld (mew-summary-folder-name))
	     (msg (mew-summary-message-number)))
	(when (and bogo fld msg)
	  (with-temp-buffer
	    (let ((coding-system-for-write mew-cs-text-for-write)
		  (coding-system-for-read mew-cs-text-for-read))
	      (insert-file-contents (mew-expand-folder fld msg))
	      (if (not (y-or-n-p (format "Add `%s' to %s? " (mew-header-get-value "From:")
					 (if white "*noSpam* list" "*SPAM* list"))))
		  (error "Nothing to do.")
		(when (string= (mew-header-get-value "From:")
			       "emacs-w3m-admin@namazu.org")
		  (goto-char (point-min))
		  (if (and (re-search-forward "^------- Forwarded Message" nil t)
			   (re-search-forward "^Received: " nil t))
		      (delete-region (point-min) (line-beginning-position))
		    (error "???")))
		(apply 'call-process-region (point-min) (point-max) bogo
		       'delete (current-buffer) nil
		       (if white '("-S" "-n") '("-s"))))))
	  (if white
	      (when (string= fld "+spam")
		(mew-summary-refile-body '("+inbox")))
	    (when (not (string= fld "+spam"))
	      (mew-summary-refile-body '("+spam"))))
	  (message "%s/%s to %s" fld msg (if white "noSpam." "SPAM!!"))))))))
 
(defun mew-bogo-check (&optional arg)
  "Bogofilter を使った Spam check。C-u なら region。"
  (interactive "P")
  (if (mew-summary-or-virtual-p)
      (mew-summary-not-in-queue
       (mew-summary-not-in-draft
	(if arg
	    (mew-bogo-check-region)
	  (mew-bogo-check-one))))
    (message "This command can be used in Mew.")))
 
(defun mew-bogo-check-region ()
  (let* ((begend (mew-summary-get-region))
	 (spam 0)
	 (total 0)
	 beg end pos)
    (when begend
      (setq beg (car begend))
      (setq end (cdr begend))
      (save-restriction
	(narrow-to-region beg end)
	(mew-decode-syntax-delete)
	(when (mew-sinfo-get-disp-msg)
	  (mew-summary-toggle-disp-msg))
	(goto-char (point-min))
	(setq pos (point))
	(while (not (eobp))
	  (setq total (1+ total))
	  (when (mew-bogo-check-one)
	    (setq spam (1+ spam)))
	  (forward-line 1)))
      (message "%d/%d detect." spam total))))
  
(defun mew-bogo-check-one ()
  (save-excursion
    (mew-summary-goto-message)
    (let* ((fld (mew-summary-folder-name))
	   (msg (mew-summary-message-number))
	   (bogo (mew-which-exec "bogofilter"))
	   ret)
      (when (and bogo fld msg)
	(with-temp-buffer
	  (let ((coding-system-for-write mew-cs-text-for-write)
		(coding-system-for-read mew-cs-text-for-read))
	    (insert-file-contents (mew-expand-folder fld msg))
	    (goto-char (point-min))
	    (when (string= (mew-header-get-value "From:")
			   "emacs-w3m-admin@namazu.org")
	      (goto-char (point-min))
	      (if (and (re-search-forward "^------- Forwarded Message" nil t)
		       (re-search-forward "^Received: " nil t))
		  (delete-region (point-min) (line-beginning-position))
		(error "???")))
	    (apply 'call-process-region (point-min) (point-max) bogo
		   'delete (current-buffer) nil '("-u" "-e" "-p"))
	    (goto-char (point-min))
	    (when (and (re-search-forward "^X-Bogosity: " nil t)
		       (looking-at "Yes"))
	      (setq ret t))))
	(if ret
	    (progn
	      (when (not (string= fld "+spam"))
		(mew-summary-refile-body '("+spam")))
	      (message "%s/%s is Spam!!" fld msg))
	  (when (string= fld "+spam")
	    (mew-summary-refile-body '("+inbox")))
	  (message "%s/%s is noSpam." fld msg))
	ret))))
 
思いっ切りぼくの環境に依存しているので注意。だけど、本当は、mew-pop-command-dele() にで組み込んで spam のチェックをしないとあまりうれしくないな。

書いている人: 白井秀行 (mailto:shirai@meadowy。org)
訪問して下さった人: 今日: 人, 昨日: , 過去: 人 (2007年5月10日から)
RDF Feed