donate notify not fin

This commit is contained in:
Jay
2018-07-19 00:40:07 +08:00
parent fa11f24e3a
commit 9d964268e8
11 changed files with 204 additions and 4 deletions
+8
View File
@@ -4,12 +4,19 @@ const DB = require('@libs/database')
const {
msgSplit
} = require('./parser')
const event = require('@root/event')
class WS {
constructor () {
/** @type {WebSocket} */
this.ws = null
this.join = []
event.on('twitchJoin', (channel) => {
this.joinChannel(channel)
})
event.on('twitchSend', data => {
this.sendMsg(data.channel, data.message)
})
}
runBot () {
@@ -89,6 +96,7 @@ class WS {
joinChannel (channel = 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 (this.join.indexOf(channel) !== -1) return null
this.ws.send(`JOIN #${channel.trim()}`)
this.join.push(channel.trim())
}