diff --git a/src/matrixroomhandler.ts b/src/matrixroomhandler.ts index d45a964e0c79f517eb6902f1e7baf0b34e3c0c86..e397a68d33baa09aa57405bd75bf9a45ddc416cd 100644 --- a/src/matrixroomhandler.ts +++ b/src/matrixroomhandler.ts @@ -86,7 +86,15 @@ export class MatrixRoomHandler { } public HandleInvite(event: any) { - // Do nothing yet. + log.info("MatrixRoomHandler", "Received invite for " + event.state_key + " in room " + event.room_id); + if (event.state_key === this.botUserId) { + this.bridge.getIntent().getClient().joinRoom(event.room_id).catch(err => { + log.error("MatrixRoomHandler", err); + setTimeout(() => { + this.bridge.getIntent().join(event.room_id).catch(err => log.error("MatrixRoomHandler", err)); + }, 5000); // Retry the join in 5 seconds if it failed the first time + }); + } } public OnAliasQuery (alias: string, aliasLocalpart: string): Promise<any> {