From 34973daf471e85651c635861afd0d26b5a00dc4d Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Wed, 24 May 2017 20:50:16 -0700 Subject: [PATCH] why not invite if room is restricted --- pnut-bridge.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pnut-bridge.py b/pnut-bridge.py index 5c4cda1..586eadb 100644 --- a/pnut-bridge.py +++ b/pnut-bridge.py @@ -72,6 +72,17 @@ class ChannelMonitor(threading.Thread): 'user_id': user_id } r = requests.post(url, params=params) + if r.status_code == 403: + self.invite_room(user_id, roomid) + requests.post(url, params=params) + + def invite_room(self, user_id, roomid): + url = self.matrix_api_url + '/rooms/' + roomid + "/invite" + params = { + 'access_token': self.matrix_api_token, + 'user_id': user_id + } + r = requests.post(url, params=params) def send_message(self, roomid, msg): url = self.matrix_api_url + '/rooms/' + roomid +'/send/m.room.message' + '/' + str(self.txId)