-
Notifications
You must be signed in to change notification settings - Fork 2
/
principal.js
81 lines (70 loc) · 2.2 KB
/
principal.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const options = { cors: { origin: "*" } };
const express = require("express");
const app = express();
const server = require("http").createServer(app);
const io = require("socket.io")(server, options);
const tmi = require("tmi.js");
const { username, channel } = require("tmi.js/lib/utils");
const ConfigClient = require("./ConfigClient.js");
const config = new ConfigClient();
const optss = {
options: {
debug: true,
},
connection: {
cluster: "aws",
reconnect: true,
},
identity: {
username: config.canalBot,
password: config.token,
},
//channels: [config.botFica],
channels: config._canalBotFica,
};
// Cria um cliente tmi com nossas opções
const client = new tmi.client(optss);
const Spikador = require("./Spikador.js");
const fala = new Spikador(client);
const AudiosMP3 = require("./AudiosMP3.js");
const audio = new AudiosMP3(client);
client.connect();
client.on("connected", entrouNoChatDaTwitch);
client.on("message", mensagemChegou);
app.use(express.static("public"));
server.listen(3000);
io.on("connection", (socket) => {
socket.on("joinRoom", (channel) => {
socket.join(channel);
});
});
function entrouNoChatDaTwitch(endereco, porta) {
console.log(`* Bot entrou no endereço ${endereco}:${porta}`);
}
function mensagemChegou(channel, user, message, self) {
if (self) return;
if (message.toLowerCase() === "!spikadorbot") {
client.say(channel, `Spikador é um bot de reprodução de falas e audios`);
}
if (message.toLowerCase() === "!careca") {
audio.careca(channel, user, message, io);
}
if (message.toLowerCase() === "!alemao") {
audio.alemao(channel, user, message, io);
}
if (message.toLowerCase() === "!aplausos") {
audio.aplausos(channel, user, message, io);
}
if (message.toLowerCase() === "!catuxa") {
audio.catuxa(channel, user, message, io);
}
if (message.toLowerCase() === "!fds") {
audio.fds(channel, user, message, io);
}
if (message.toLowerCase() === "!rojao") {
audio.rojao(channel, user, message, io);
}
if (message.indexOf("!spikador") === 0) {
fala.run(channel, user, message, io);
}
}