Commit 819bc3f5 authored by Benjamin Graillot's avatar Benjamin Graillot

From est dans l'objet message

parent 63edcc2a
......@@ -33,7 +33,7 @@ DEFAULT_SENDER = 'wiki@crans.org'
UPDATES = {
'wiki@crans.org' : (
# fonction de pré-traitement du mail
lambda mail: quopri.decodestring(email.message_from_bytes(mail.lines[1]).get_payload()).decode('utf-8').replace('\r', ''), {
lambda mail: quopri.decodestring(mail.get_payload()).decode('utf-8').replace('\r', ''), {
Update.edit: (
lambda **kwargs: '\x0310,99{page}\x0f \x033,99{user}\x0f \x0399,99{comment}\x0f \x0315,99(r{rev})'.format(**kwargs) if kwargs['comment']\
......@@ -170,6 +170,7 @@ def idle_loop(host, user, password, ninja):
yield from imap_client.wait_hello_from_server()
yield from imap_client.login(user, password)
yield from imap_client.select()
print('Running...')
while True:
idle = yield from imap_client.idle_start(timeout=60)
msgs = yield from imap_client.wait_server_push()
......@@ -178,6 +179,7 @@ def idle_loop(host, user, password, ninja):
for m in msgs:
if m.endswith(' EXISTS'):
mail = yield from imap_client.uid('fetch', m[:-7], '(RFC822)')
mail = email.message_from_bytes(mail.lines[1])
sender = mail['From']
if sender not in UPDATES:
sender = DEFAULT_SENDER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment