revert new thing
This commit is contained in:
parent
3ef1bccb7a
commit
7fe2b0fa12
|
@ -97,6 +97,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||
|
||||
// MPP to Discord
|
||||
gClient.on('a', async msg => {
|
||||
if (msg.p._id == gClient.getOwnParticipant()._id) return;
|
||||
var id = msg.p._id.substr(0,6);
|
||||
var name = sanitizeName(msg.p.name);
|
||||
var content = msg.a;
|
||||
|
@ -106,26 +107,28 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||
|
||||
// Discord to MPP
|
||||
{
|
||||
//let msgQueue = [];
|
||||
let msgQueue = [];
|
||||
dClient.on('message', async message => {
|
||||
if (message.channel.id !== channel.id || message.author.id == dClient.user.id || !message.member /*|| message.content.startsWith('!')*/) return;
|
||||
var str = message.cleanContent;
|
||||
var aname = message.author.tag;
|
||||
//if (str.startsWith('/') || str.startsWith('\\'))
|
||||
// msgQueue.push(`⤹ ${aname}`);
|
||||
//else
|
||||
if (str.startsWith('/') || str.startsWith('\\'))
|
||||
msgQueue.push(`⤹ ${aname}`);
|
||||
else
|
||||
str = `${aname}: ${str}`;
|
||||
//if (str.startsWith('\\')) str = str.slice(1);
|
||||
if (str.startsWith('\\')) str = str.slice(1);
|
||||
if (message.attachments.size > 0) str += ' ' + message.attachments.map(a => a.url).join(' ');
|
||||
if (str.length > 512) str = str.substr(0,511) + '…';
|
||||
//msgQueue.push(str);
|
||||
gClient.sendArray([{m:'a', message: str}]);
|
||||
if (gClient.isConnected()) message.delete();
|
||||
if (str.length > 512) {
|
||||
str = str.substr(0,511) + '…';
|
||||
message.react('⚠');
|
||||
}
|
||||
msgQueue.push(str);
|
||||
});
|
||||
//setInterval(()=>{
|
||||
// let message = msgQueue.shift();
|
||||
// if (message) gClient.sendArray([{m:'a', message}]);
|
||||
//}, 1600); // just about fastest without exceeding quota; I figured quota is 4 messages per 6 seconds in lobbies
|
||||
setInterval(()=>{
|
||||
let message = msgQueue.shift();
|
||||
if (message) gClient.sendArray([{m:'a', message}]);
|
||||
//todo wait moment to see if message got through then react warning if didnt
|
||||
}, 1600); // just about fastest without exceeding quota; I figured quota is 4 messages per 6 seconds in lobbies
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue