From 1fa75f3e27dc612faa2147fea0c9f818d898d5d4 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 9 Jul 2012 15:37:08 +0200 Subject: [PATCH] initial git commit --- mail2taskwarrior | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 mail2taskwarrior diff --git a/mail2taskwarrior b/mail2taskwarrior new file mode 100755 index 0000000..15a0b9e --- /dev/null +++ b/mail2taskwarrior @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 +# +# Add a task to taskwarrior via email. Makes use of the taskw Python bindings. +# +# http://taskwarrior.org +# https://github.com/ralphbean/taskw +# +# For use with procmail or maildrop. Example using maildrop's .mailfilter: +# +# +# if ($SIZE < 8192 && /^From:.*myaddress@example.com/ && /^To:.*taskwarrior@/) +# { +# log "add task via mail2taskwarrior" +# xfilter "devel/mail2taskwarrior/mail2taskwarrior" +# exit +# } +# + +from taskw import TaskWarrior +import time +import email +import fileinput + +msg_string = "" +for line in fileinput.input(): + msg_string += line + +msg = email.message_from_string(msg_string) +subject = email.header.make_header(email.header.decode_header(msg.get("Subject"))) + +w = TaskWarrior() +w.task_add(str(subject), due=str(int(time.time())))