twitch-bot/libs/botClient.js
2018-02-12 23:08:42 +08:00

24 lines
406 B
JavaScript

const WebSocket = require('ws')
const config = require('../config')
const ws = new WebSocket(`wss://${config.twitch.chat_host}:443`, 'irc')
ws.on('open', () => {
})
ws.on('message', (data) => {
if (typeof data !== 'string') data = data.toString()
})
ws.on('error', (err) => {
console.error(err)
})
ws.on('close', (code, reason) => {
console.log('exit', code, reason)
})
module.exports = ws