slackpost: Decode reply as quoted-printable text

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-06-16 11:42:02 -04:00
parent 14e44c1734
commit 673bac86bc
1 changed files with 3 additions and 2 deletions

View File

@ -4,6 +4,7 @@
import slack
import sys
import quopri
from email.parser import Parser
@ -35,7 +36,8 @@ split = headers.get_payload().split(reply)
# We should have a two element list. The thread id
# is in the text at the start of the second element.
#
thread_id = split[-1].split()[0]
quoted = quopri.decodestring(split[-1]).decode()
thread_id = quoted.split()[0]
if thread_id.find("thread=") == -1:
print("Thread ID missing!")
sys.exit(1)
@ -56,7 +58,6 @@ for line in split[0].split("\n"):
while lines[-1] != "":
lines.pop(len(lines) - 1)
text = ' '.join(lines).strip()
print(text)
thread = slack.find_thread(thread_id)