-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
110 lines (87 loc) · 2.34 KB
/
index.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
import tmi from "tmi.js";
import OBSWebSocket from "obs-websocket-js";
import dotenv from "dotenv";
import ObserveBitrate from "./functions/ObserveBitrate.js";
dotenv.config();
const client = new tmi.Client({
channels: [process.env.CHANNEL_NAME],
identity: {
username: process.env.USER,
password: process.env.PASSWORD,
},
});
const sessionSettings = {
disableAuto: false,
currenScene: "live",
offlineAttemp: 0,
};
const obs = new OBSWebSocket();
obs.connect(process.env.OBS_ADDRESS, process.env.OBS_PASSWORD).then(
(info) => {
console.log("Connected and identified", info);
},
(err) => {
console.log(err);
}
);
obs.on("SwitchScenes", (data) => {
return client.say(
`#${process.env.CHANNEL_NAME}`,
`Pomyślnie zmieniono scene na ${data.sceneName}.`
);
});
obs.on("error", (err) => {
console.error("socket error:", err);
});
client.connect();
client.on("message", (channel, tags, message, self) => {
if (self || !message.startsWith("!")) return;
const args = message.slice(1).split(" ");
const command = args.shift().toLowerCase();
const badges = tags.badges || {};
const isBroadcaster = badges.broadcaster;
const isMod = badges.moderator;
const isModUp = isBroadcaster || isMod;
if (command === "brb") {
if (isModUp) {
obs.call("SetCurrentProgramScene", { sceneName: "brb" });
return client.say(
channel,
`@${tags.username}, Scena została zmieniona na ZARAZ WRACAM NOWAY`
);
}
return;
}
if (command === "stop") {
if (isModUp) {
obs.call("StopStream");
return client.say(
channel,
`@${tags.username}, Stream został zakończony papa`
);
}
return;
}
if (command === "live") {
if (isModUp) {
obs.call("SetCurrentProgramScene", { sceneName: "live" });
return client.say(channel, `@${tags.username}, Już wszystko działa aok`);
}
return;
}
if (command === "disable") {
if (isModUp) {
sessionSettings.disableAuto = !sessionSettings.disableAuto;
return client.say(
channel,
`@${tags.username}, ${
sessionSettings.disableAuto === false ? "Włączyłeś" : "Wyłączyłeś"
} interaktywne zmienianie sceny.`
);
}
return;
}
});
setInterval(async () => {
await ObserveBitrate(sessionSettings, obs, client);
}, 15 * 1000);