[Python-checkins] r56576 - tracker/instances/python-dev-spambayes-integration/detectors/busybody.py tracker/instances/python-dev-spambayes-integration/detectors/tellteam.py
erik.forsberg
python-checkins at python.org
Fri Jul 27 16:20:03 CEST 2007
Author: erik.forsberg
Date: Fri Jul 27 16:20:02 2007
New Revision: 56576
Modified:
tracker/instances/python-dev-spambayes-integration/detectors/busybody.py
tracker/instances/python-dev-spambayes-integration/detectors/tellteam.py
Log:
Don't send messages classified as spam.
Modified: tracker/instances/python-dev-spambayes-integration/detectors/busybody.py
==============================================================================
--- tracker/instances/python-dev-spambayes-integration/detectors/busybody.py (original)
+++ tracker/instances/python-dev-spambayes-integration/detectors/busybody.py Fri Jul 27 16:20:02 2007
@@ -22,6 +22,16 @@
from roundup import roundupdb, hyperdb
+def is_spam(db, msgid):
+ cutoff_score = float(db.config.detectors['SPAMBAYES_SPAM_CUTOFF'])
+
+ msg = db.getnode("msg", msgid)
+ if msg.has_key('spambayes_score') and \
+ msg['spambayes_score'] > cutoff_score:
+ return False
+ return True
+
+
def busyreaction(db, cl, nodeid, oldvalues):
''' busybody mail
'''
@@ -36,7 +46,7 @@
else:
note = cl.generateChangeNote(nodeid, oldvalues)
- for msgid in msgIDS:
+ for msgid in filter(lambda x: is_spam(db, x), msgIDS):
try:
cl.send_message(nodeid, msgid, note, sendto)
except roundupdb.MessageSendError, message:
Modified: tracker/instances/python-dev-spambayes-integration/detectors/tellteam.py
==============================================================================
--- tracker/instances/python-dev-spambayes-integration/detectors/tellteam.py (original)
+++ tracker/instances/python-dev-spambayes-integration/detectors/tellteam.py Fri Jul 27 16:20:02 2007
@@ -1,5 +1,14 @@
from roundup import roundupdb
+def is_spam(db, msgid):
+ cutoff_score = float(db.config.detectors['SPAMBAYES_SPAM_CUTOFF'])
+
+ msg = db.getnode("msg", msgid)
+ if msg.has_key('spambayes_score') and \
+ msg['spambayes_score'] > cutoff_score:
+ return False
+ return True
+
def newissuetriage(db, cl, nodeid, oldvalues):
''' Copy a message about new issues to a triage address,
set in detectors/config.ini
@@ -14,9 +23,10 @@
triage_email = []
if not triage_email:
return
- for msgid in cl.get(nodeid, 'messages'):
+ for msgid in filter(lambda x: is_spam(db, x), cl.get(nodeid, 'messages')):
try:
# note: last arg must be a list
+
cl.send_message(nodeid, msgid, change_note, triage_email)
except roundupdb.MessageSendError, message:
raise roundupdb.DetectorError, message
More information about the Python-checkins
mailing list