[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r18759: {projects} Add an alert (on by default) for every successful package re (in projects/gettor: . gettor)



Author: ioerror
Date: 2009-03-03 10:38:44 -0500 (Tue, 03 Mar 2009)
New Revision: 18759

Modified:
   projects/gettor/GetTor.py
   projects/gettor/TODO
   projects/gettor/gettor/config.py
   projects/gettor/gettor/responses.py
   projects/gettor/sample-gettorrc
Log:
Add an alert (on by default) for every successful package request. This allows a user to know one way or the other that they were at least able to reach the GetTor robot. This adds a new option delayAlert = True to the config and is by default set to True. The text is static but can be modified if anyone wants it to be configurable.


Modified: projects/gettor/GetTor.py
===================================================================
--- projects/gettor/GetTor.py	2009-03-03 08:39:49 UTC (rev 18758)
+++ projects/gettor/GetTor.py	2009-03-03 15:38:44 UTC (rev 18759)
@@ -188,10 +188,12 @@
     # Initialize response
     srcEmail = conf.getSrcEmail()
     # Bail out if someone tries to be funny
+    # XXX TODO: Implement a blacklist check here
     if (srcEmail == replyTo):
         log.error(_("Won't send myself emails."))
         return False
 
+    delayAlert = conf.getDelayAlert()
     resp = gettor.responses.gettorResponse(conf, replyLang, logLang)
     signature = rmail.hasVerifiedSignature()
     log.info(_("Signature is: %s") % str(signature))
@@ -214,6 +216,24 @@
         package = rmail.getPackage()
         if package != None:
             log.info(_("Package: %s selected.") % str(package))
+            log.info(_("Sending delay alert email: %s") % str(delayAlert))
+            if delayAlert == True:
+                message = _("""
+    Hello, This is the "gettor" robot.
+
+    Thank you for your request. It was sucessfully understood. Your request is
+    currently being processed. Your package should arrive within the next ten
+    minutes.
+
+    If you require any additional help, please feel free to contact a human
+    at the following support email address: tor-assistants@xxxxxxxxxxxxxx
+
+        """)
+
+                status = resp.sendGenericMessage(srcEmail, replyTo, message)
+                if status != True:
+                    log.info(_("Failed to send delay alert")
+
             status = resp.sendPackage(srcEmail, replyTo, packageList[package])
             if status != True:
                 log.info(_("Failed at attempt to send package: %s") % str(package))

Modified: projects/gettor/TODO
===================================================================
--- projects/gettor/TODO	2009-03-03 08:39:49 UTC (rev 18758)
+++ projects/gettor/TODO	2009-03-03 15:38:44 UTC (rev 18759)
@@ -13,6 +13,3 @@
 - Better exception catching when the local SMTP rejects the email
     - Perhaps we want to email the admin of GetTor with the error?
     - Perhaps we want to respond to the user with a useful message?
-- Do we want to instantly email the user with a "please wait" message for large
-files that may take a while to arrive?
-    - Do we want to do it for every message?

Modified: projects/gettor/gettor/config.py
===================================================================
--- projects/gettor/gettor/config.py	2009-03-03 08:39:49 UTC (rev 18758)
+++ projects/gettor/gettor/config.py	2009-03-03 15:38:44 UTC (rev 18759)
@@ -25,6 +25,7 @@
      logSubSystem = nothing
      logFile = /dev/null
      localeDir = /usr/share/locale
+     delayAlert = True
 
  Note that you can set from none to any of these values in your config file.
  Values you dont provide will be taken from the defaults in 'useConf'.
@@ -46,6 +47,9 @@
                             also set to something useful
  localeDir:     This is where the 'en/LC_MESSAGES/gettor.mo' or 
                 'whateverlang/LC_MESSAGES/gettor.mo' should go
+ delayAlert:    If set to True (the default), a message will be sent to any
+                user who has properly requested a package. The message confirms
+                that a package was selected and will be sent.
 
  If no valid config file is provided to __init__, gettorConf will try to use
  '~/.gettorrc' as default config file. If that fails, the default values from
@@ -90,7 +94,8 @@
                         "locale":       ("en",                      "global"),
                         "logSubSystem": ("nothing",                 "global"),
                         "logFile":      ("/dev/null",               "global"),
-                        "localeDir":    ("/usr/share/locale",       "global")}
+                        "localeDir":    ("/usr/share/locale",       "global"),
+                        "delayAlert":   (True,                    "global")}
 
         # One ConfigParser instance to read the actual values from config
         self.config = ConfigParser.ConfigParser()
@@ -166,6 +171,9 @@
     def getLocaleDir(self):
         return self.useConf["localeDir"][0]
 
+    def getDelayAlert(self):
+        return self.useConf["delayAlert"][0]
+
 if __name__ == "__main__" :
     c = gettorConf()
     print "# This is a suitable default configuration. Tune to fit your needs."

Modified: projects/gettor/gettor/responses.py
===================================================================
--- projects/gettor/gettor/responses.py	2009-03-03 08:39:49 UTC (rev 18758)
+++ projects/gettor/gettor/responses.py	2009-03-03 15:38:44 UTC (rev 18759)
@@ -96,6 +96,17 @@
 
         return status
 
+    def sendGenericMessage(self, source, destination, message):
+        """ Send a helpful message of some sort """
+        self.setLang(self.mailLang)
+        help = self.constructMessage(message, source, destination)
+        try:
+            status = self.sendMessage(help, source, destination)
+        except:
+            status = False
+        self.setLang(self.logLang)
+        return status
+
     def sendPackage(self, source, destination, filename):
         """ Send a message with an attachment to the user interacting with us """
         self.setLang(self.mailLang)

Modified: projects/gettor/sample-gettorrc
===================================================================
--- projects/gettor/sample-gettorrc	2009-03-03 08:39:49 UTC (rev 18758)
+++ projects/gettor/sample-gettorrc	2009-03-03 15:38:44 UTC (rev 18759)
@@ -7,7 +7,8 @@
 wlstatedir  = /tmp/wl/
 distdir     = /tmp/distdir/
 packdir     = /tmp/packdir/
-locale        = en
+locale      = en
+delayalert  = True
 logSubSystem= stdout
 logFile     = /tmp/logfile
 localDir    = /tmp/i18n/