aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2018-11-20 13:07:35 +0800
committerAaron LI <aly@aaronly.me>2018-11-20 13:07:35 +0800
commitb0c2023b6563f7caf55bf90d88137ea9166f0056 (patch)
tree7d396df834cb67d7db9456f1cc433f66facf14cf
parent3c9ebac37b25907858c6c1e029b2f08a88bdbb86 (diff)
downloaddotfiles-b0c2023b6563f7caf55bf90d88137ea9166f0056.tar.bz2
alot: Add hooks.py
-rw-r--r--_config/alot/hooks.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/_config/alot/hooks.py b/_config/alot/hooks.py
new file mode 100644
index 0000000..9447689
--- /dev/null
+++ b/_config/alot/hooks.py
@@ -0,0 +1,19 @@
+#
+# ~/.config/alot/hooks.py
+#
+# Credits:
+# * https://github.com/pazz/alot/wiki/Contrib-Hooks
+#
+
+import re
+
+
+# Check for missing attachment before sending
+#
+async def pre_envelope_send(ui, dbm, __):
+ p = r'.*([Aa]ttach|附件|附图)'
+ e = ui.current_buffer.envelope
+ if re.match(p, e.body, re.DOTALL) and not e.attachments:
+ msg = 'No attachments. Send anyway?'
+ if not (await ui.choice(msg, select='yes')) == 'yes':
+ raise Exception()