forked from mtane0412/tanenobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
42 lines (37 loc) · 982 Bytes
/
main.js
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
42
"use strict";
require('dotenv').config();
let lobby = "";
const command = require("./command");
const tmi = require('tmi.js');
const client = new tmi.Client({
options: { debug: true, messagesLogLevel: "info" },
connection: {
reconnect: true,
secure: true
},
identity: {
username: 'tanenobot',
password: process.env.TWITCH_TOKEN
},
channels: [ 'tanenob' ]
});
client.connect().catch(console.error);
client.on('message', (channel, tags, message, self) => {
if(self) return; // ignore mesasges from tanenobot
if(message.startsWith('!')) {
const reply = command(tags, message);
if(reply === "GetLobbyInfo") {
//get lobby info
client.say(channel, "Lobby Info: " + lobby);
}
else if(reply === "SetLobby") {
//set lobby
lobby = message.substring(7);
client.say(channel, "Lobby is set to: " + lobby);
}
else if (reply != ""){
// お兄ちゃんに何か返すときだけ、返信しちゃお!
client.say(channel, reply);
}
}
});