From b0c2023b6563f7caf55bf90d88137ea9166f0056 Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Tue, 20 Nov 2018 13:07:35 +0800 Subject: alot: Add hooks.py --- _config/alot/hooks.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 _config/alot/hooks.py 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() -- cgit v1.2.2