use afew for tagging
This commit is contained in:
parent
9fd709b6f2
commit
20f299ed36
29
config/afew/config
Normal file
29
config/afew/config
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
[TagOrContact.1]
|
||||||
|
query = to:felixvdj.*@posteo.be OR to:felix.vanderjeugt.*@posteo.net
|
||||||
|
|
||||||
|
[Filter.1]
|
||||||
|
message = Tag messages to my UGent account
|
||||||
|
query = to:felix.vanderjeugt@ugent.be
|
||||||
|
tags = +ugent
|
||||||
|
|
||||||
|
[Filter.2]
|
||||||
|
message = Tag messages to my Zeus account
|
||||||
|
query = to:felixvdj@zeus.ugent.be
|
||||||
|
tags = +zeus
|
||||||
|
|
||||||
|
[Filter.3]
|
||||||
|
message = The Dodona alias
|
||||||
|
query = to:dodona@ugent.be
|
||||||
|
tags = +dodona
|
||||||
|
|
||||||
|
[Filter.4]
|
||||||
|
message = The Unipept alias
|
||||||
|
query = to:unipept@ugent.be
|
||||||
|
tags = +unipept
|
||||||
|
|
||||||
|
[ListMailsFilter]
|
||||||
|
|
||||||
|
[Filter.0]
|
||||||
|
message = Add all new messages to the inbox
|
||||||
|
query = tag:new
|
||||||
|
tags = +unread;-new
|
33
config/afew/only_contacts.py
Normal file
33
config/afew/only_contacts.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
from afew.filters.BaseFilter import Filter
|
||||||
|
from afew.FilterRegistry import register_filter
|
||||||
|
|
||||||
|
from khard.config import Config
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
@register_filter
|
||||||
|
class TagOrContact(Filter):
|
||||||
|
message = 'Allow only tagged messages from non-contacts'
|
||||||
|
user = None
|
||||||
|
domain = None
|
||||||
|
|
||||||
|
def __init__(self, database, **kwargs):
|
||||||
|
super(TagOrContact, self).__init__(database, **kwargs)
|
||||||
|
self._extract_tag_re = re.compile(f'[^+]+(\+(?P<tag>[^@]+))?@[^@]+')
|
||||||
|
self._bare_email_re = re.compile(r'[^<]*<(?P<email>[^@<>]+@[^@<>]+)>')
|
||||||
|
self._contactbook = Config().abook
|
||||||
|
|
||||||
|
def handle_message(self, message):
|
||||||
|
recipient = message.get_header('Delivered-To')
|
||||||
|
match = self._extract_tag_re.fullmatch(recipient)
|
||||||
|
if match is None: return # wrong email
|
||||||
|
|
||||||
|
if match.group('tag'):
|
||||||
|
self.add_tags(message, match['tag'])
|
||||||
|
else:
|
||||||
|
sender = message.get_header('From')
|
||||||
|
if '<' in sender: sender = self._bare_email_re.fullmatch(sender)['email']
|
||||||
|
if self._contactbook.search(sender):
|
||||||
|
self.add_tags(message, 'contact')
|
||||||
|
else:
|
||||||
|
self.add_tags(message, 'killed')
|
118
config/afew/spam_filter.py
Normal file
118
config/afew/spam_filter.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
from afew.filters.BaseFilter import Filter
|
||||||
|
from afew.FilterRegistry import register_filter
|
||||||
|
|
||||||
|
spammers = """
|
||||||
|
hbguirui.net
|
||||||
|
foodcongress2019.com
|
||||||
|
congresssummit.com
|
||||||
|
icmsquare.net
|
||||||
|
austinpublishinggroup.us
|
||||||
|
hindawi.com
|
||||||
|
internationalmeeting.org
|
||||||
|
openaccessusa.com
|
||||||
|
journal.aoam.email
|
||||||
|
mailpanda.com
|
||||||
|
scientificres.org
|
||||||
|
scifedconferences.com
|
||||||
|
insightmeetings.net
|
||||||
|
wgc-2019.com
|
||||||
|
intopenaccess.com
|
||||||
|
walla.co.il
|
||||||
|
innofine.in
|
||||||
|
escientificres.com
|
||||||
|
xceptdom.com
|
||||||
|
aoam.info
|
||||||
|
cambridgescholars.com
|
||||||
|
mra-journal.org
|
||||||
|
jimsindia.org
|
||||||
|
service.cyagenbio.com
|
||||||
|
oatext-alerts.net
|
||||||
|
2019ibc.com
|
||||||
|
eclinmed.org
|
||||||
|
innovationinfo.net
|
||||||
|
intechopen.com
|
||||||
|
neurologyspeakerexperts.org
|
||||||
|
conferencesinternational.org
|
||||||
|
oap-lifescience.org
|
||||||
|
synpeptide.com.cn
|
||||||
|
americaseminars.com
|
||||||
|
oatextjournals.com
|
||||||
|
connectcyagen.com
|
||||||
|
oatjournals.com
|
||||||
|
meetingsintl.com
|
||||||
|
scientglobal.org
|
||||||
|
research101.site
|
||||||
|
biochemistryjournals.org
|
||||||
|
functionalfoodcenter.com
|
||||||
|
bio-congress.com
|
||||||
|
oatext-news.org
|
||||||
|
ptzjournals.com
|
||||||
|
glazovsky.co.ua
|
||||||
|
wcfnconference2018.com
|
||||||
|
iacrlrd2019.com
|
||||||
|
scientificfederation.com
|
||||||
|
journalres.org
|
||||||
|
bangng.org
|
||||||
|
eurosciconmeetings.com
|
||||||
|
renecon.eu
|
||||||
|
kebiochem.cn
|
||||||
|
reg-med2018.com
|
||||||
|
edelweisspublications.info
|
||||||
|
ibc-congress.com
|
||||||
|
sciencescholastic.com
|
||||||
|
journals.hindawi.com
|
||||||
|
bioevents.net
|
||||||
|
clinicalopenaccess.org
|
||||||
|
easummit.net
|
||||||
|
networkwithexpert.com
|
||||||
|
cmcb2019.com
|
||||||
|
eursciconevent.com
|
||||||
|
cmedu.org
|
||||||
|
oatextjournal.info
|
||||||
|
alliedinternational.org
|
||||||
|
kingfisherbiotech.com
|
||||||
|
meettheglobalexpert.com
|
||||||
|
tonirovany.biz.ua
|
||||||
|
doveproofreading.com
|
||||||
|
clinicalcasereports.editor@protonmail.ch
|
||||||
|
scireslitoa.com
|
||||||
|
academiapublishing.org
|
||||||
|
editorialscience.org
|
||||||
|
pepcon-2019.com
|
||||||
|
oap-journals.net
|
||||||
|
klserv.com
|
||||||
|
keimra.org
|
||||||
|
oap-cancer.org
|
||||||
|
cmcb-2019.com
|
||||||
|
rebuilding-the-raindrops.ovh
|
||||||
|
gavinconferences.org
|
||||||
|
iwbbio.org
|
||||||
|
usp-pl.net
|
||||||
|
biochemjournals.com
|
||||||
|
sophia.isabella010@yahoo.com
|
||||||
|
aimspress6.com
|
||||||
|
proteinresearch.website
|
||||||
|
linkinscience.com
|
||||||
|
esciencemedicine.com
|
||||||
|
cellmech-bio2018.com
|
||||||
|
oap-journals.org
|
||||||
|
sara.wallner78@gmail.com
|
||||||
|
evajones290@gmail.com
|
||||||
|
news.caister.com
|
||||||
|
scientificfederation.info
|
||||||
|
imrjournal.email
|
||||||
|
oap-journals.com
|
||||||
|
frontiermeetings.com
|
||||||
|
submitresearch.online
|
||||||
|
editor.factor21@daum.net
|
||||||
|
"""
|
||||||
|
|
||||||
|
@register_filter
|
||||||
|
class KnownSpammers(Filter):
|
||||||
|
|
||||||
|
def __init__(self, database, **kwargs):
|
||||||
|
super(KnownSpammers, self).__init__(database, **kwargs)
|
||||||
|
self.query = ' or '.join(f'from:{s}' for s in spammers.split('\n') if s)
|
||||||
|
|
||||||
|
def handle_message(self, message):
|
||||||
|
self.add_tags(message, 'spam')
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
initial_command = search NOT tag:killed AND NOT tag:archived
|
initial_command = search not tag:archived
|
||||||
periodic_hook_frequency = 60
|
periodic_hook_frequency = 60
|
||||||
|
|
||||||
attachment_prefix = /data/temporary
|
attachment_prefix = /data/temporary
|
||||||
@ -11,8 +11,8 @@ editor_cmd = "dvtm 'vis %s'"
|
|||||||
[[posteo]]
|
[[posteo]]
|
||||||
realname = Felix Van der Jeugt
|
realname = Felix Van der Jeugt
|
||||||
address = felix.vanderjeugt@posteo.net
|
address = felix.vanderjeugt@posteo.net
|
||||||
aliases = felixvdj@zeus.ugent.be
|
aliases = felixvdj@zeus.ugent.be, ninewise@posteo.be
|
||||||
alias_regexp = felix\.vanderjeugt\+.+@posteo.net
|
alias_regexp = (felix\.vanderjeugt\+.+@posteo.net|felixvdj\+.+@posteo\.be)
|
||||||
gpg_key = 68FF561137C38F9618E97339AF25A2C2862AA368
|
gpg_key = 68FF561137C38F9618E97339AF25A2C2862AA368
|
||||||
sendmail_command = /usr/bin/msmtp --account=posteo -t
|
sendmail_command = /usr/bin/msmtp --account=posteo -t
|
||||||
sent_box = maildir:///data/mail/posteo/Sent
|
sent_box = maildir:///data/mail/posteo/Sent
|
||||||
@ -65,7 +65,7 @@ editor_cmd = "dvtm 'vis %s'"
|
|||||||
t = toggletags selected; move down
|
t = toggletags selected; move down
|
||||||
|
|
||||||
[[search]]
|
[[search]]
|
||||||
x = tag killed
|
x = tag spam
|
||||||
a = tag archived
|
a = tag archived
|
||||||
A = untag archived
|
A = untag archived
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ other_email=felix.vanderjeugt@ugent.be;felix.vanderjeugt@gmail.com
|
|||||||
# in the mail store.
|
# in the mail store.
|
||||||
#
|
#
|
||||||
[new]
|
[new]
|
||||||
tags=unread;new;
|
tags=new;
|
||||||
ignore=
|
ignore=
|
||||||
|
|
||||||
# Search configuration
|
# Search configuration
|
||||||
@ -61,7 +61,7 @@ ignore=
|
|||||||
# query will override that exclusion.
|
# query will override that exclusion.
|
||||||
#
|
#
|
||||||
[search]
|
[search]
|
||||||
exclude_tags=killed;deleted;spam;
|
exclude_tags=spam;
|
||||||
|
|
||||||
# Maildir compatibility configuration
|
# Maildir compatibility configuration
|
||||||
#
|
#
|
||||||
@ -86,3 +86,6 @@ exclude_tags=killed;deleted;spam;
|
|||||||
#
|
#
|
||||||
[maildir]
|
[maildir]
|
||||||
synchronize_flags=true
|
synchronize_flags=true
|
||||||
|
|
||||||
|
[query]
|
||||||
|
inbox=not tag:spam and not tag:archived
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# some filtering
|
# filtering spam
|
||||||
notmuch tag +killed -new -unread -- subject:'^[SPAM]' to:ugent
|
afew --tag --new -e SpamFilter,KnownSpammers
|
||||||
|
notmuch tag -new -- tag:spam and tag:new
|
||||||
|
|
||||||
# notify for new messages
|
# notify for new messages
|
||||||
notmuch search tag:new | cut -d' ' --complement -f1 | xargs -0 --no-run-if-empty notify-send
|
notmuch search tag:new | cut -d' ' --complement -f1 | xargs -0 --no-run-if-empty notify-send
|
||||||
|
|
||||||
# processed new messages are no longer new
|
# tagging messages
|
||||||
notmuch tag -new -- tag:new
|
afew --tag --new
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user