diff options
| author | bwarsaw | 2000-02-19 03:51:11 +0000 |
|---|---|---|
| committer | bwarsaw | 2000-02-19 03:51:11 +0000 |
| commit | bde80c7e3b4f26e8a5a34f01d3148b73751f13f4 (patch) | |
| tree | 206aec2527b474f3193d157966c13fc997b855ef /Mailman/Handlers/Replybot.py | |
| parent | 15c5b3054aad971ee027203b0d8bf39cbc8c3911 (diff) | |
| download | mailman-bde80c7e3b4f26e8a5a34f01d3148b73751f13f4.tar.gz mailman-bde80c7e3b4f26e8a5a34f01d3148b73751f13f4.tar.zst mailman-bde80c7e3b4f26e8a5a34f01d3148b73751f13f4.zip | |
Diffstat (limited to 'Mailman/Handlers/Replybot.py')
| -rw-r--r-- | Mailman/Handlers/Replybot.py | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/Mailman/Handlers/Replybot.py b/Mailman/Handlers/Replybot.py new file mode 100644 index 000000000..714636f9c --- /dev/null +++ b/Mailman/Handlers/Replybot.py @@ -0,0 +1,82 @@ +# Copyright (C) 1998 by the Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +"""Handler for auto-responses. +""" + +import string +import time +import HandlerAPI + +from Mailman import Utils +from Mailman import Message + + + +def process(mlist, msg): + # "X-Ack: No" header in the original message disables the replybot + ack = string.lower(msg.get('x-ack', '')) + if ack == 'no': + return + # Check to see if the list is even configured to autorespond to this email + # message. Note: the mailowner script sets the `toadmin' attribute. + toadmin = getattr(msg, 'toadmin', 0) + if toadmin and not mlist.autorespond_admin: + return + if not mlist.autorespond_postings: + return + # + # Now see if we're in the grace period for this sender (guaranteed to be + # lower cased). graceperiod <= 0 means always autorespond, as does an + # "X-Ack: yes" header (useful for debugging). + sender = msg.GetSender() + now = time.time() + graceperiod = mlist.autoresponse_graceperiod + if graceperiod > 0 and ack <> 'yes': + if toadmin: + quite_until = mlist.admin_responses.get(sender, 0) + else: + quite_until = mlist.postings_responses.get(sender, 0) + if quite_until > now: + return + # + # Okay, we know we're going to auto-respond to this sender, craft the + # message, send it, and update the database. + subject = 'Auto-response for the "%s" mailing list' % mlist.real_name + # Do string interpolation + d = Utils.SafeDict({'listname' : mlist.real_name, + 'listurl' : mlist.GetScriptURL('listinfo'), + 'requestemail': mlist.GetRequestEmail(), + 'adminemail' : mlist.GetAdminEmail(), + }) + if toadmin: + text = mlist.autoresponse_admin_text % d + else: + text = mlist.autoresponse_postings_text % d + outmsg = Message.UserNotification(sender, mlist.GetAdminEmail(), + subject, text) + outmsg['X-Mailer'] = 'The Mailman Replybot ' + # prevent recursions and mail loops! + outmsg['X-Ack'] = 'No' + HandlerAPI.DeliverToUser(mlist, outmsg) + # update the grace period database + if graceperiod > 0: + # graceperiod is in days, we need # of seconds + quite_until = now + graceperiod * 24 * 60 * 60 + if toadmin: + mlist.admin_responses[sender] = quite_until + else: + mlist.postings_responses[sender] = quite_until |
