Fix a bug where XMPP bridge would repeatedly ignore channels

pull/2/head
knotteye 2020-10-17 22:07:30 -05:00
parent ab082e5f95
commit 01744df3cd
1 changed files with 4 additions and 2 deletions

View File

@ -9,6 +9,7 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
var ircClient; var ircClient;
var xmppIgnore: Array<string> = []; var xmppIgnore: Array<string> = [];
var xmppJoined: Array<string> = [];
var twitchClient; var twitchClient;
var twitchArr: Array<string> = []; var twitchArr: Array<string> = [];
var discordClient; var discordClient;
@ -276,10 +277,12 @@ async function normalizeDiscordMsg(msg): Promise<string>{
} }
function xmppJoin(room: string): void{ function xmppJoin(room: string): void{
var stanza = new xmpp.Element('presence', {"to": room+'/'+config['chat']['xmpp']['nickname']}).c('x', { xmlns: 'http://jabber.org/protocol/muc' }).c('history', { maxstanzas: 0, seconds: 1}); if(xmppJoined.findIndex((e) => { return e === room }) !== -1) return;
var stanza = new xmpp.Element('presence', {"to": room+'/'+config['chat']['xmpp']['nickname']}).c('x', { xmlns: 'http://jabber.org/protocol/muc' }).c('history', { maxstanzas: 0, seconds: 0});
xmpp.conn.send(stanza); xmpp.conn.send(stanza);
xmppIgnore = xmppIgnore.concat([room]); xmppIgnore = xmppIgnore.concat([room]);
xmpp.join(room+'/'+config['chat']['xmpp']['nickname']); xmpp.join(room+'/'+config['chat']['xmpp']['nickname']);
xmppJoined = xmppJoined.concat([room]);
sleep(4000).then(() => { sleep(4000).then(() => {
xmppIgnore = xmppIgnore.filter((item) => { xmppIgnore = xmppIgnore.filter((item) => {
return item !== room; return item !== room;
@ -288,7 +291,6 @@ function xmppJoin(room: string): void{
} }
function updateXmppChan(): void{ function updateXmppChan(): void{
//simple-xmpp will ignore duplicate joins by itself so we can join repeatedly
for(var i=0;i<chatIntegration.length;i++){ for(var i=0;i<chatIntegration.length;i++){
if(chatIntegration[i]['xmpp'].trim() !== "" && chatIntegration[i]['xmpp'] !== null) xmppJoin(chatIntegration[i]['xmpp']); if(chatIntegration[i]['xmpp'].trim() !== "" && chatIntegration[i]['xmpp'] !== null) xmppJoin(chatIntegration[i]['xmpp']);
} }