update and clean
This commit is contained in:
parent
9b79f096ba
commit
a9b7e64bd9
75
conf.d/afew/BogoFilter.py
Normal file
75
conf.d/afew/BogoFilter.py
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# File : BogoFilter.py
|
||||||
|
# Author : Jeff LANCE <email@jefflance.me>
|
||||||
|
# Date : 05.05.2020
|
||||||
|
# Last Modified Date: 05.05.2020
|
||||||
|
# Last Modified By : Jeff LANCE <email@jefflance.me>
|
||||||
|
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
|
||||||
|
from afew.filters.BaseFilter import Filter
|
||||||
|
from afew.FilterRegistry import register_filter
|
||||||
|
from afew.NotmuchSettings import get_notmuch_new_tags, get_notmuch_new_query
|
||||||
|
|
||||||
|
|
||||||
|
# path to binary
|
||||||
|
bogofilter = '/usr/bin/bogofilter'
|
||||||
|
|
||||||
|
|
||||||
|
class pOutput(object):
|
||||||
|
path = ''
|
||||||
|
mailType = ''
|
||||||
|
|
||||||
|
|
||||||
|
# function for creating objects out of
|
||||||
|
# bogofilter output
|
||||||
|
def processOutput(path, mailType):
|
||||||
|
processed = pOutput()
|
||||||
|
processed.path = path
|
||||||
|
processed.mailType = mailType
|
||||||
|
return processed
|
||||||
|
|
||||||
|
|
||||||
|
# classification function
|
||||||
|
def isSpam(path):
|
||||||
|
p = subprocess.run([bogofilter, "-BT", path], stdout=subprocess.PIPE)
|
||||||
|
output = p.stdout.decode('ascii')
|
||||||
|
output = output.split(" ")
|
||||||
|
processed = processOutput(output[0], output[1])
|
||||||
|
# output has to be decoded
|
||||||
|
if processed.mailType == 'U' or processed.mailType == 'H':
|
||||||
|
return False
|
||||||
|
if processed.mailType == 'S':
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@register_filter
|
||||||
|
class BogoFilter(Filter):
|
||||||
|
message = 'Filter message with bogofilter'
|
||||||
|
tags = ['+spam']
|
||||||
|
tags_blacklist = ['killed', 'spam']
|
||||||
|
|
||||||
|
@property
|
||||||
|
def query(self):
|
||||||
|
"""
|
||||||
|
Need to read the notmuch settings first. Using a property here
|
||||||
|
so that the setting is looked up on demand.
|
||||||
|
"""
|
||||||
|
return get_notmuch_new_query()
|
||||||
|
|
||||||
|
|
||||||
|
def handle_message(self, message):
|
||||||
|
if isSpam(message.get_filename()):
|
||||||
|
self.remove_tags(message, 'new')
|
||||||
|
self.add_tags(message, 'spam')
|
||||||
|
elif not isSpam(message.get_filename()):
|
||||||
|
self.remove_tags(message, 'new')
|
||||||
|
self.add_tags(message, 'inbox')
|
||||||
|
|
||||||
|
super().handle_message(message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# vim:ft=python
|
53
conf.d/afew/config
Normal file
53
conf.d/afew/config
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
; File : config
|
||||||
|
; Author : Jeff LANCE <email@jefflance.me>
|
||||||
|
; Date : 10.02.2018
|
||||||
|
; Last Modified Date: 06.05.2020
|
||||||
|
; Last Modified By : Jeff LANCE <email@jefflance.me>
|
||||||
|
|
||||||
|
#[SpamFilter]
|
||||||
|
#spam_tag = scum
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#[BogoFilter]
|
||||||
|
|
||||||
|
|
||||||
|
[KillThreadsFilter]
|
||||||
|
|
||||||
|
|
||||||
|
[ListMailsFilter]
|
||||||
|
|
||||||
|
|
||||||
|
[SentMailsFilter]
|
||||||
|
sent_tag = sent
|
||||||
|
|
||||||
|
|
||||||
|
[ArchiveSentMailsFilter]
|
||||||
|
|
||||||
|
|
||||||
|
[Filter.1]
|
||||||
|
message = Tag all messages from work
|
||||||
|
query = 'from:STolsy@ac-creteil.fr'
|
||||||
|
tag = +evariste
|
||||||
|
|
||||||
|
|
||||||
|
[Filter.2]
|
||||||
|
message = Tag all message from @mala.fr addresses
|
||||||
|
query = 'from:games@mala.fr'
|
||||||
|
tag = +MOI
|
||||||
|
|
||||||
|
|
||||||
|
[InboxFilter]
|
||||||
|
|
||||||
|
|
||||||
|
[MailMover]
|
||||||
|
folders = jeff.lance@mala.fr/archives jeff.lance@mala.fr/drafts jeff.lance@mala.fr/inbox jeff.lance@mala.fr/junk jeff.lance@mala.fr/sent jeff.lance@mala.fr/trash
|
||||||
|
rename = True
|
||||||
|
jeff.lance@mala.fr/sent= 'tag:deleted':jeff.lance@mala.fr/trash 'NOT tag:sent':jeff.lance@mala.fr/inbox
|
||||||
|
jeff.lance@mala.fr/archives = 'tag:deleted':jeff.lance@mala.fr/trash 'NOT tag:archive':jeff.lance@mala.fr/inbox
|
||||||
|
jeff.lance@mala.fr/drafts= 'tag:deleted':jeff.lance@mala.fr/trash 'NOT tag:draft':jeff.lance@mala.fr/inbox
|
||||||
|
jeff.lance@mala.fr/junk = 'tag:deleted':jeff.lance@mala.fr/trash 'NOT tag:spam':jeff.lance@mala.fr/inbox
|
||||||
|
jeff.lance@mala.fr/inbox = 'tag:spam':jeff.lance@mala.fr/junk 'tag:deleted':jeff.lance@mala.fr/trash
|
||||||
|
jeff.lance@mala.fr/trash = 'NOT tag:deleted':jeff.lance@mala.fr/inbox
|
||||||
|
|
||||||
|
|
||||||
|
; vim:ft=dosini
|
45
conf/msmtprc
Normal file
45
conf/msmtprc
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
# Set default values for all following accounts.
|
||||||
|
defaults
|
||||||
|
auto_from on
|
||||||
|
tls_trust_file /etc/ssl/certs/ca-certificates.crt
|
||||||
|
syslog on
|
||||||
|
#logfile /var/log/msmtp.log
|
||||||
|
|
||||||
|
# MaLa
|
||||||
|
account jeff.lance@mala.fr
|
||||||
|
host ssl0.ovh.net
|
||||||
|
port 465
|
||||||
|
auth on
|
||||||
|
tls on
|
||||||
|
tls_starttls off
|
||||||
|
user jeff.lance@mala.fr
|
||||||
|
passwordeval "echo $(secret-tool lookup service smtp user jeff.lance@mala.fr)"
|
||||||
|
auto_from off
|
||||||
|
from jeff.lance@mala.fr
|
||||||
|
|
||||||
|
# GMail
|
||||||
|
account mathslance@gmail.com
|
||||||
|
host imap.gmail.com
|
||||||
|
port 465
|
||||||
|
auth on
|
||||||
|
tls on
|
||||||
|
tls_starttls off
|
||||||
|
user mathslance@gmail.com
|
||||||
|
passwordeval "echo $(secret-tool lookup service smtp user mathslance@gmail.com)"
|
||||||
|
auto_from off
|
||||||
|
from mathslance@gmail.com
|
||||||
|
|
||||||
|
# # Ac-Montpellier
|
||||||
|
# account montpellier
|
||||||
|
# host smtp.ac-montpellier.fr
|
||||||
|
# port 587
|
||||||
|
# auth plain
|
||||||
|
# tls on
|
||||||
|
# tls_starttls on
|
||||||
|
# user jlance
|
||||||
|
# passwordeval "echo $(secret-tool lookup service smtp user jlance)"
|
||||||
|
# auto_from off
|
||||||
|
# from jean-francois.lance@ac-montpellier.fr
|
||||||
|
|
||||||
|
# Set a default account
|
||||||
|
account default : jeff.lance@mala.fr
|
@ -1,10 +1,16 @@
|
|||||||
- link:
|
- link:
|
||||||
${HOME}/.mbsynrc:
|
|
||||||
path: conf/mbsyncrc
|
|
||||||
${HOME}/.notmuch-config:
|
|
||||||
path: conf/notmuch-config
|
|
||||||
${HOME}/.config/astroid:
|
${HOME}/.config/astroid:
|
||||||
path: conf.d/astroid
|
glob: true
|
||||||
|
path: conf.d/astroid/*
|
||||||
|
${HOME}/.config/afew:
|
||||||
|
glob: true
|
||||||
|
path: conf.d/afew/*
|
||||||
${HOME}/.config/alot:
|
${HOME}/.config/alot:
|
||||||
path: conf.d/alot
|
path: conf.d/alot
|
||||||
|
${HOME}/.mbsyncrc:
|
||||||
|
path: conf/mbsyncrc
|
||||||
|
${HOME}/.msmtprc:
|
||||||
|
path: conf/msmtprc
|
||||||
|
${HOME}/.notmuch-config:
|
||||||
|
path: conf/notmuch-config
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user