From 69240f21fad17a78f50ae97f31f89c05c40b44cb Mon Sep 17 00:00:00 2001 From: Lamp Date: Fri, 14 Dec 2018 05:31:38 +0000 Subject: [PATCH] Fix asumption of p only on join, also added announce on name change Closes #3 again --- src/mppbridger/index.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mppbridger/index.js b/src/mppbridger/index.js index 68cc76a..6e3de6e 100755 --- a/src/mppbridger/index.js +++ b/src/mppbridger/index.js @@ -179,14 +179,20 @@ global.createMPPbridge = function createMPPbridge(room, DiscordChannelID, site = - // announce join/leave - gClient.on("p", async participant => { - dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`); + // announce join/leave/rename + gClient._events.p.unshift(async participant => { + if (gClient.ppl[participant.id]) { // is update + let oldName = gClient.ppl[participant.id].name, newName = participant.name; + if (newName != oldName) + dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(oldName)}** changed their name to **${sanitizeName(newName)}**___`); + } else { // is join + dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`); + } }); gClient._events.bye.unshift(async msg => { var participant = MPP.client.ppl[msg.p]; dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** left the room.___`); - }) + });