diff options
| author | bwarsaw | 2007-05-31 05:01:00 +0000 |
|---|---|---|
| committer | bwarsaw | 2007-05-31 05:01:00 +0000 |
| commit | d0bd1d07a472db4b897ddf81c04ae3602cba9297 (patch) | |
| tree | eaa63652e7bd0a82a57443f9c89746ae254027bd /Mailman/Handlers/Replybot.py | |
| parent | 8c1fa18658dc730b53ddbb4766549a4fe595e453 (diff) | |
| download | mailman-d0bd1d07a472db4b897ddf81c04ae3602cba9297.tar.gz mailman-d0bd1d07a472db4b897ddf81c04ae3602cba9297.tar.zst mailman-d0bd1d07a472db4b897ddf81c04ae3602cba9297.zip | |
Diffstat (limited to 'Mailman/Handlers/Replybot.py')
| -rw-r--r-- | Mailman/Handlers/Replybot.py | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/Mailman/Handlers/Replybot.py b/Mailman/Handlers/Replybot.py index d63169eb2..18fc83ced 100644 --- a/Mailman/Handlers/Replybot.py +++ b/Mailman/Handlers/Replybot.py @@ -20,13 +20,16 @@ import time import logging +from string import Template + from Mailman import Message from Mailman import Utils from Mailman.i18n import _ -from Mailman.SafeDict import SafeDict log = logging.getLogger('mailman.error') +__i18n_templates__ = True + def process(mlist, msg, msgdata): @@ -69,42 +72,26 @@ def process(mlist, msg, msgdata): quiet_until = mlist.postings_responses.get(sender, 0) if quiet_until > now: return - # # Okay, we know we're going to auto-respond to this sender, craft the # message, send it, and update the database. realname = mlist.real_name subject = _( - 'Auto-response for your message to the "%(realname)s" mailing list') - # Do string interpolation - d = SafeDict({'listname' : realname, - 'listurl' : mlist.GetScriptURL('listinfo'), - 'requestemail': mlist.GetRequestEmail(), - # BAW: Deprecate adminemail; it's not advertised but still - # supported for backwards compatibility. - 'adminemail' : mlist.GetBouncesEmail(), - 'owneremail' : mlist.GetOwnerEmail(), - }) - # Just because we're using a SafeDict doesn't mean we can't get all sorts - # of other exceptions from the string interpolation. Let's be ultra - # conservative here. + 'Auto-response for your message to the "$realname" mailing list') + # Do string interpolation into the autoresponse text + d = dict(listname = realname, + listurl = mlist.GetScriptURL('listinfo'), + requestemail = mlist.request_address, + owneremail = mlist.owner_address, + ) if toadmin: rtext = mlist.autoresponse_admin_text elif torequest: rtext = mlist.autoresponse_request_text else: rtext = mlist.autoresponse_postings_text - # Using $-strings? - if getattr(mlist, 'use_dollar_strings', 0): - rtext = Utils.to_percent(rtext) - try: - text = rtext % d - except Exception: - log.error('Bad autoreply text for list: %s\n%s', - mlist.internal_name(), rtext) - text = rtext - # Wrap the response. - text = Utils.wrap(text) - outmsg = Message.UserNotification(sender, mlist.GetBouncesEmail(), + # Interpolation and Wrap the response text. + text = Utils.wrap(Template(rtext).safe_substitute(d)) + outmsg = Message.UserNotification(sender, mlist.bounces_address, subject, text, mlist.preferred_language) outmsg['X-Mailer'] = _('The Mailman Replybot') # prevent recursions and mail loops! |
