fix 2
This commit is contained in:
parent
006b2f2d77
commit
1b01804230
|
@ -5,9 +5,9 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||||
var webhooks = await channel.fetchWebhooks();
|
var webhooks = await channel.fetchWebhooks();
|
||||||
var webhook = webhooks.filter(w => w.token).first() || await channel.createWebhook("sdfadffg");
|
var webhook = webhooks.filter(w => w.token).first() || await channel.createWebhook("sdfadffg");
|
||||||
|
|
||||||
{ // discord message sending
|
//todo figure out new way to buffer
|
||||||
let msgBuffer = [];
|
function dSend(msg, options) {
|
||||||
function _dSend(options) {
|
if (arguments.length == 1) options = msg;
|
||||||
|
|
||||||
if (options.content?.length > 2000) {
|
if (options.content?.length > 2000) {
|
||||||
options.attachments ||= [];
|
options.attachments ||= [];
|
||||||
|
@ -18,26 +18,12 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||||
let username = gClient.channel && gClient.channel._id || room;
|
let username = gClient.channel && gClient.channel._id || room;
|
||||||
if (username.length > 80) username = username.substr(0,79) + '…';
|
if (username.length > 80) username = username.substr(0,79) + '…';
|
||||||
|
|
||||||
webhook.send(Object.assign(options, {username})).catch(error => {
|
webhook.send(options).catch(error => {
|
||||||
handleError(error, `webhook fail in ${channel.id}`);
|
handleError(error, `webhook fail in ${channel.id}`);
|
||||||
channel.send(options).catch(error => handleError(error, `send fail in ${channel.id} after webhook send fail`));
|
channel.send(options).catch(error => handleError(error, `send fail in ${channel.id} after webhook send fail`));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
function dSend(msg, options) {
|
|
||||||
if (arguments.length == 1) options = msg;
|
|
||||||
else {
|
|
||||||
options ||= {};
|
|
||||||
options.content = msg;
|
|
||||||
}
|
|
||||||
msgBuffer.push(options);
|
|
||||||
}
|
|
||||||
setInterval(()=>{
|
|
||||||
if (msgBuffer.length == 0) return;
|
|
||||||
_dSend(msgBuffer.join('\n'));
|
|
||||||
msgBuffer = [];
|
|
||||||
}, 3000);
|
|
||||||
}
|
|
||||||
|
|
||||||
const gClient = new Client(uri);
|
const gClient = new Client(uri);
|
||||||
if (uri == "wss://mppclone.com:8443") gClient.token = config.mpc_token; //todo hmm
|
if (uri == "wss://mppclone.com:8443") gClient.token = config.mpc_token; //todo hmm
|
||||||
|
|
Loading…
Reference in New Issue