forked from HackingTV/DefectorBot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
41 lines (31 loc) · 889 Bytes
/
bot.js
File metadata and controls
41 lines (31 loc) · 889 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
const api = require('./api')
const TwitchBot = require('twitch-bot')
const logger = require('./logger')
const channel = 'hackingtv'
const Bot = new TwitchBot({
username: 'defectorbot',
oauth: process.env.OAUTH_TOKEN,
channels: [channel]
})
Bot.on('join', channel => {
logger.info(`Joined channel: ${channel}`)
})
Bot.on('error', err => {
logger.error('something happened to the bot in twitch', err)
})
Bot.on('part', channel => {
logger.info(`leaving the channel ${channel}`)
Bot.join(channel)
})
Bot.on('join', channel => {
logger.info(`joining the channel ${channel}`)
})
Bot.on('message', async chatter => {
if(chatter.message === '!defectors') {
let defectors = await api.getDefectors()
Bot.say(`The Defectors: ${defectors}`)
} else if (chatter.message === '!help') {
Bot.say('Use !defectors to list the defectors')
}
})
module.exports = Bot