New Comment Spam Plugin.
"Blake Winton" <blake-dlUKtbW3TlBcVw/[email protected]>
| Newsgroups | gmane.comp.web.pyblosxom.user |
|---|---|
| Message-ID | <[email protected]> |
The attached plugin runs all comments through Akismet, to determine whether they're spam or not. I just whipped it up last night, so if anyone has any ideas on how to improve it, I'm all ears. You'll need to install the akismet python library from http://www.voidspace.org.uk/python/modules.shtml#akismet Also on that page are instructions on how to get the required 'akismet_key' config variable. (The page calls it a "Wordpress Key".) Later, Blake. ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ pyblosxom-users mailing list pyblosxom-users-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org https://lists.sourceforge.net/lists/listinfo/pyblosxom-users
akismetComments.py
(application/octet-stream, 2.1 KB)
""" Run comments through Akismet to see whether to reject them or not. Copyright 2006 Blake Winton <[email protected]>. """ __author__ = "Blake Winton" __version__ = "1.0" __url__ = "http://weblog.latte.ca/" __description__ = "Run comments through Akismet." import sys import time try: from akismet import Akismet except ImportError: pass def verify_installation(request): retval = 1 try: from akismet import Akismet except ImportError: print "Missing module 'akismet'." retval = 0 config = request.getConfiguration() if not config.has_key("akismet_key"): print "Missing required key 'akismet_key'" retval = 0 try: from akismet import Akismet a = Akismet( config['akismet_key'], config['base_url'] ) if not a.verify_key(): print "Invalid akismet_key" retval = 0 except ImportError: print "Unknown error!" retval = 0 return retval def cb_comment_reject(args): req = args["request"] comment = args["comment"] blog_config = req.getConfiguration() data = req.getData() http = req.getHttp() entry = data['entry_list'][0] a = Akismet( blog_config['akismet_key'], blog_config['base_url'] ) data = { 'user_ip': comment['ipaddress'], 'user_agent': http['HTTP_USER_AGENT'], 'referrer': http['HTTP_REFERER'], 'permalink': '', 'comment_type': 'comment', 'comment_author': comment['author'], 'comment_author_email': comment['email'], 'comment_author_url': comment['link'], #'SERVER_ADDR': os.environ.get('SERVER_ADDR', ''), #'SERVER_ADMIN': os.environ.get('SERVER_ADMIN', ''), #'SERVER_NAME': os.environ.get('SERVER_NAME', ''), #'SERVER_PORT': os.environ.get('SERVER_PORT', ''), #'SERVER_SIGNATURE': os.environ.get('SERVER_SIGNATURE', ''), #'SERVER_SOFTWARE': os.environ.get('SERVER_SOFTWARE', ''), 'HTTP_ACCEPT': http['HTTP_ACCEPT'], } if not a.verify_key(): return 0 if a.comment_check(comment['description'], data): return (1, "I'm sorry, your comment was rejected by Akismet.") return 0