-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
52 lines (49 loc) · 1.23 KB
/
bot.js
File metadata and controls
52 lines (49 loc) · 1.23 KB
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
require("dotenv").config();
const tmi = require("tmi.js");
const fs = require("fs");
const optinons = {
options: {
debug: true,
},
connecntion: {
cluster: "aws",
reconnect: true,
},
identity: {
username: process.env.USERNAME,
password: process.env.PASS,
},
channels: [process.env.CHANNEL],
};
let bots = ["supibot", "pwgud", "streamelements", "nightbot"];
let symbols = ["!", "$", "/", "="];
const client = new tmi.client(optinons);
client.connect();
client.on("chat", function (channel, username, message) {
if (!bots.includes(username.username) && !message.includes("https://")) {
if (!symbols.includes(message.charAt(0))) {
let messLog = message + "|\r\n";
fs.appendFile("messages.txt", messLog, function (error) {
if (error) {
console.log(error);
}
});
}
}
fs.readFile("users.txt", "utf8", function (error, data) {
if (error) {
console.log(error);
}
if (
!data.includes(username.username) &&
!bots.includes(username.username)
) {
let userLog = username.username + "|\r\n";
fs.appendFile("users.txt", userLog, function (error) {
if (error) {
console.log(error);
}
});
}
});
});