aboutsummaryrefslogtreecommitdiffstats
path: root/_config/alot/hooks.py
blob: 94476891a7bf0ac3ab6f2ef9ec31d136f9d40176 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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()