diff --git a/src/bot.js b/src/bot.js index efe4f8c..82c9046 100644 --- a/src/bot.js +++ b/src/bot.js @@ -109,11 +109,10 @@ class OcrccBot { let chatOffline = true; try { - const data = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) - const members = data.chunk + const roomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID) + const members = Object.keys(roomMembers["joined"]); - members.forEach(member => { - const memberId = member.user_id; + members.forEach(memberId => { const user = this.client.getUser(memberId); if ( user && @@ -142,18 +141,17 @@ class OcrccBot { this.localStorage.removeItem(`${roomId}-waiting`) try { - const groupUsers = await this.client.getGroupUsers(this.config.FACILITATOR_GROUP_ID) - const roomMembers = await this.client.getJoinedRoomMembers(roomId) + const facilitatorsRoomMembers = await this.client.getJoinedRoomMembers(this.config.FACILITATOR_ROOM_ID) + const supportRoomMembers = await this.client.getJoinedRoomMembers(roomId) - const roomMemberIds = Object.keys(roomMembers["joined"]); - const groupMemberIds = groupUsers["chunk"] + const roomMembersIds = Object.keys(supportRoomMembers["joined"]); + const facilitatorsIds = Object.keys(facilitatorsRoomMembers["joined"]); - if (!roomMemberIds || !groupMemberIds) return; + if (!roomMembersIds || !facilitatorsIds) return; - const facilitatorsIds = groupMemberIds.map(f => f.user_id); facilitatorsIds.forEach(f => { - if (!roomMemberIds.includes(f)) { + if (!roomMembersIds.includes(f)) { this.kickUserFromRoom(roomId, f); } });