Add !fixusers command to re-invite missing users to SMS chats
This commit is contained in:
parent
f32ee82029
commit
eba11701cd
24
main.js
24
main.js
@ -533,6 +533,30 @@ client.login("m.login.password", {"user": settings.matrixuser, "password": setti
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getContent().body.toLowerCase().startsWith("!fixusers")) {
|
||||
sendMatrixNotice(event.getRoomId(), "Inviting missing users across all SMS chats.");
|
||||
|
||||
client.getJoinedRooms().then(function (rooms) {
|
||||
var roomlist = rooms.joined_rooms;
|
||||
for (var i = 0; i < roomlist.length; i++) {
|
||||
(function (roomid) {
|
||||
console.log(roomid);
|
||||
client.getJoinedRoomMembers(roomid).then(function (joined) {
|
||||
var members = Object.keys(joined.joined);
|
||||
console.log(members);
|
||||
for (var j = 0; j < settings.inviteusers.length; j++) {
|
||||
if (members.indexOf(settings.inviteusers[j]) == -1) {
|
||||
client.invite(roomid, settings.inviteusers[j]);
|
||||
}
|
||||
}
|
||||
});
|
||||
})(roomlist[i]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
var matches = room.name.match(/SMS_([1-9][0-9]+)(?:_([1-9][0-9]+))?/g);
|
||||
console.log(event.getRoomId());
|
||||
if (matches == null || (matches.length != 1 && matches.length != 2)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user