From 83695acae7241103149cf607a763885f70cca046 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Tue, 2 May 2017 22:43:23 -0700 Subject: [PATCH] handle image post --- appservice.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/appservice.py b/appservice.py index 7c3bca1..ac39ab6 100644 --- a/appservice.py +++ b/appservice.py @@ -40,6 +40,15 @@ def on_receive_events(transaction): else: token = app.config['MATRIX_PNUT_TOKEN'] text = "* " + get_displayname(event["user_id"]) + " " + event['content']['body'] + elif event['content']['msgtype'] == 'm.image': + imgurl = app.config['MATRIXBOT_HOST'] + '/_matrix/media/r0/download/' + event['content']['url'][6:] + if user: + token = user.pnut_token + text = "" + else: + token = app.config['MATRIX_PNUT_TOKEN'] + text = "[" + get_displayname(event["user_id"]) + "] " + text += event['content']['body'] + " : " + imgurl else: text = None