updated my personal email address
[edward.git] / edward
diff --git a/edward b/edward
index ed47182fbe4165dccffd3f37f40fd7db42ce91f6..d7443927cabc24fa373c66b8019015be5d981dd2 100755 (executable)
--- a/edward
+++ b/edward
@@ -51,7 +51,7 @@ from email.mime.nonmultipart    import MIMENonMultipart
 
 import edward_config
 
-langs = ["de", "el", "en", "es", "fr", "it", "ja", "pt-br", "ro", "ru", "tr"]
+langs = ["de", "el", "en", "es", "fr", "it", "ja", "pt-br", "ro", "ru", "tr", "zh"]
 
 """This list contains the abbreviated names of reply languages available to
 edward."""
@@ -267,11 +267,13 @@ def main ():
 
     print_reply_only = handle_args()
 
+    email_bytes = sys.stdin.buffer.read()
+
+    test_auto_reply(email_bytes)
+
     gpgme_ctx = get_gpg_context(edward_config.gnupghome,
                               edward_config.sign_with_key)
 
-    email_bytes = sys.stdin.buffer.read()
-
     # do this twice so sigs can be verified with newly imported keys
     parse_pgp_mime(email_bytes, gpgme_ctx)
     email_struct = parse_pgp_mime(email_bytes, gpgme_ctx)
@@ -1243,6 +1245,32 @@ def is_key_usable (key_obj):
         return False
 
 
+def test_auto_reply (email_bytes):
+    """Test whether email is auto-generated
+
+    If the email is autogenerated, edward quits without sending a response.
+    This is not a perfect test. Some auto-responses will go undetected.
+
+    Args:
+        email_bytes: the byte string from of the email
+
+    Returns:
+        Nothing, or exits the program
+    """
+
+    email_struct = email.parser.BytesHeaderParser().parsebytes(email_bytes)
+
+    auto_submitted = email_struct['Auto-Submitted']
+
+    if auto_submitted == None or auto_submitted == "no" \
+            or auto_submitted == "No":
+
+        return
+
+    debug("autoreply")
+    exit(0)
+
+
 def email_to_reply_to_subject (email_bytes):
     """Returns the email's To:, Reply-To: (or From:), and Subject: fields