slackpost: Properly strip out reply markers
Remove all lines beginning with ">", and the line immediately before them. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d07bf33f44
commit
29815fc28b
|
@ -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")
|
||||
|
|
10
slackpost.py
10
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)
|
||||
|
|
Loading…
Reference in New Issue