fix twitch irc leave bug
This commit is contained in:
parent
a767ef3869
commit
ba4dba3429
@ -65,7 +65,7 @@ class WS {
|
|||||||
|
|
||||||
for (let i in darr) {
|
for (let i in darr) {
|
||||||
// parse message
|
// parse message
|
||||||
console.log('IRC:::: ', darr[i])
|
console.log('IRC::: > ', darr[i])
|
||||||
msgSplit(this.ws, darr[i]).then(() => { /* pass */ })
|
msgSplit(this.ws, darr[i]).then(() => { /* pass */ })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,12 +87,12 @@ class WS {
|
|||||||
// release pool connection
|
// release pool connection
|
||||||
await db.release()
|
await db.release()
|
||||||
|
|
||||||
this.joinChannel = []
|
|
||||||
if (result !== null && result.rowCount > 0) {
|
if (result !== null && result.rowCount > 0) {
|
||||||
for (let row of result.rows) {
|
for (let row of result.rows) {
|
||||||
if ('name' in row) {
|
if ('name' in row) {
|
||||||
this.ws.send('JOIN #' + row.name)
|
this.joinChannel(row.name)
|
||||||
this.join.push(row.name)
|
// this.ws.send('JOIN #' + row.name)
|
||||||
|
// this.join.push(row.name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,6 +142,7 @@ class WS {
|
|||||||
if (channel === null || typeof channel !== 'string' || channel.trim().length === 0) return null
|
if (channel === null || typeof channel !== 'string' || channel.trim().length === 0) return null
|
||||||
if (message === null || typeof message !== 'string' || message.trim().length === 0) return null
|
if (message === null || typeof message !== 'string' || message.trim().length === 0) return null
|
||||||
if (this.join.indexOf(channel) === -1) return null
|
if (this.join.indexOf(channel) === -1) return null
|
||||||
|
console.log(`IRC::: < ${`PRIVMSG #${channel} :${message}`}`)
|
||||||
this.ws.send(`PRIVMSG #${channel} :${message}`)
|
this.ws.send(`PRIVMSG #${channel} :${message}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ class WS {
|
|||||||
if (this.ws === null || !('send' in this.ws) || typeof this.ws.send !== 'function') return null
|
if (this.ws === null || !('send' in this.ws) || typeof this.ws.send !== 'function') return null
|
||||||
if (channel === null || typeof channel !== 'string' || channel.trim().length === 0) return null
|
if (channel === null || typeof channel !== 'string' || channel.trim().length === 0) return null
|
||||||
if (this.join.indexOf(channel) !== -1) return null
|
if (this.join.indexOf(channel) !== -1) return null
|
||||||
|
console.log(`IRC::: < ${`JOIN #${channel.trim()}`}`)
|
||||||
this.ws.send(`JOIN #${channel.trim()}`)
|
this.ws.send(`JOIN #${channel.trim()}`)
|
||||||
this.join.push(channel.trim())
|
this.join.push(channel.trim())
|
||||||
}
|
}
|
||||||
|
@ -6,12 +6,13 @@ const config = require('@config/index')
|
|||||||
*/
|
*/
|
||||||
const msgSplit = async function (ws, msg) {
|
const msgSplit = async function (ws, msg) {
|
||||||
if (!msg || typeof msg !== 'string') return null
|
if (!msg || typeof msg !== 'string') return null
|
||||||
let txtarr = msg.split(' ')
|
let txtarr = msg.trim().split(' ')
|
||||||
|
|
||||||
if (txtarr.length > 2) {
|
if (txtarr.length >= 2) {
|
||||||
// server heartbeat message
|
// server heartbeat message
|
||||||
if (/^ping$/i.test(txtarr[0])) {
|
if (/^ping$/i.test(txtarr[0])) {
|
||||||
// reply server heartbeat
|
// reply server heartbeat
|
||||||
|
console.log(`IRC::: < ${`PONG ${txtarr[1]}`}`)
|
||||||
ws.send(`PONG ${txtarr[1]}`)
|
ws.send(`PONG ${txtarr[1]}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user