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)