From 91ede1edc705cd97736026eb6f8b5c11c0367e09 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Tue, 9 Jan 2018 16:28:53 -0800 Subject: [PATCH] handle invite for direct chat through the bot resolves issue #16 --- appservice.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/appservice.py b/appservice.py index e8d707c..cc492af 100644 --- a/appservice.py +++ b/appservice.py @@ -149,19 +149,10 @@ def on_receive_events(transaction): if event['content']['membership'] == 'invite' and 'is_direct' in event['content'] and event['content']['is_direct'] == True: logging.info('>> GOT PRIVATE INVITE') - txId += 1 - url = app.config['MATRIX_HOST'] - url += '/_matrix/client/r0/join/' + event['room_id'] - url += "?access_token=" + app.config['MATRIX_AS_TOKEN'] - r = requests.post(url, headers={"Content-Type": "application/json"}, - data=json.dumps({})) - if r.status_code == 200: - addadminrm = MatrixAdminRooms(matrix_id=event['sender'], room_id=event['room_id']) - db.session.add(addadminrm) - db.session.commit() - else: - print(r.status_code) - print(r.text) + cmdbot.on_invite(event) + addadminrm = MatrixAdminRooms(matrix_id=event['sender'], room_id=event['room_id']) + db.session.add(addadminrm) + db.session.commit() elif event['content']['membership'] == 'invite': logging.info('>> GOT ROOM INVITE')