From 29815fc28bc98a41135b17747bbf191c53dbb869 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 27 May 2015 11:10:47 -0400 Subject: [PATCH] slackpost: Properly strip out reply markers Remove all lines beginning with ">", and the line immediately before them. Signed-off-by: Anna Schumaker --- slack/chat.py | 4 +--- slackpost.py | 10 +++++++++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/slack/chat.py b/slack/chat.py index fe28216..7a510e5 100644 --- a/slack/chat.py +++ b/slack/chat.py @@ -3,9 +3,7 @@ # from . import api from . import auth -from urllib import request def postMessage(channel, text): - post = request.quote(text) api.call("chat.postMessage", token = auth.token(), channel = channel, - text = post, as_user = True, parse = "full") + text = text, as_user = True, parse = "full") diff --git a/slackpost.py b/slackpost.py index 641f6f2..f671de1 100755 --- a/slackpost.py +++ b/slackpost.py @@ -25,5 +25,13 @@ for c in slack.channels.list(): if channel == None: sys.exit(1) -text = headers.get_payload().split("\n")[0] +lines = headers.get_payload().strip().split("\n") + +# Strip out quoted text +if lines[-1][0] == ">": + while lines[-1][0] == ">": + lines.pop(-1) + lines.pop(-1) + +text = ' '.join(lines).strip() channel.post(text)