aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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()