add facilitators to chatroom
This commit is contained in:
parent
ebc48141e2
commit
d9724bd52e
20
src/index.js
20
src/index.js
@ -41,6 +41,7 @@ const botName = 'Help Bot'
|
|||||||
const username = 'help-bot'
|
const username = 'help-bot'
|
||||||
const password = 'ocrccdemo'
|
const password = 'ocrccdemo'
|
||||||
const userId = "@help-bot:rhok.space"
|
const userId = "@help-bot:rhok.space"
|
||||||
|
const waitingRoomId = '!pYVVPyFKacZeKZbWyz:rhok.space'
|
||||||
|
|
||||||
let awaitingAgreement = {}
|
let awaitingAgreement = {}
|
||||||
|
|
||||||
@ -85,7 +86,17 @@ const sendMessage = (client, roomId, msgText) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const notifyFacilitators = (client, roomId) => {
|
const notifyFacilitators = (client, roomId) => {
|
||||||
|
client.getJoinedRoomMembers(waitingRoomId)
|
||||||
|
.then((members) => {
|
||||||
|
logger.log("info", "MEMBERS")
|
||||||
|
logger.log("info", members)
|
||||||
|
Object.keys(members["joined"]).forEach((member) => {
|
||||||
|
if (member !== userId)
|
||||||
|
client.invite(roomId, member)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// const notif = `There is a support seeker waiting. Go to https://riot.im/app/#/room/${roomId} to respond.`
|
||||||
|
// sendMessage(client, waitingRoomId, notif)
|
||||||
}
|
}
|
||||||
|
|
||||||
client.login('m.login.password', {
|
client.login('m.login.password', {
|
||||||
@ -120,11 +131,14 @@ client.login('m.login.password', {
|
|||||||
// Automatically join all room invitations
|
// Automatically join all room invitations
|
||||||
client.on("RoomMember.membership", (event, member) => {
|
client.on("RoomMember.membership", (event, member) => {
|
||||||
if (member.membership === "invite" && member.userId === userId) {
|
if (member.membership === "invite" && member.userId === userId) {
|
||||||
|
logger.log("info", "Auto-joining room " + member.roomId)
|
||||||
client.joinRoom(member.roomId)
|
client.joinRoom(member.roomId)
|
||||||
.then(() => client.setRoomEncryption(member.roomId, ENCRYPTION_CONFIG))
|
.then(() => client.setRoomEncryption(member.roomId, ENCRYPTION_CONFIG))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
sendMessage(client, member.roomId, 'Do you want to continue?')
|
if (member.roomId !== waitingRoomId) {
|
||||||
awaitingAgreement[member.roomId] = true
|
sendMessage(client, member.roomId, 'Do you want to continue?')
|
||||||
|
awaitingAgreement[member.roomId] = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user