Initial commit

This commit is contained in:
Patrick Müller 2021-04-19 13:43:54 +02:00
commit fc7bcf62ae
4 changed files with 151 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
.idea/
node_modules/
*.iml

52
bot.js Normal file
View File

@ -0,0 +1,52 @@
const tmi = require('tmi.js');
// Define configuration options
const opts = {
identity: {
username: "",
password: ""
},
channels: [
"yiggalow"
]
};
// Create a client with our options
const client = new tmi.client(opts);
// Register our event handlers (defined below)
client.on('message', onMessageHandler);
client.on('connected', onConnectedHandler);
// Connect to Twitch:
client.connect();
// Called every time a message comes in
function onMessageHandler(target, context, msg, self) {
if (self) {
return;
} // Ignore messages from the bot
// Remove whitespace from chat message
const commandName = msg.trim();
// If the command is known, let's execute it
if (commandName === '!dice') {
const num = rollDice();
client.say(target, `You rolled a ${num}`);
console.log(`* Executed ${commandName} command`);
} else {
console.log(`* Unknown command ${commandName}`);
}
}
// Function called when the "dice" command is issued
function rollDice() {
const sides = 6;
return Math.floor(Math.random() * sides) + 1;
}
// Called every time the bot connects to Twitch chat
function onConnectedHandler(addr, port) {
console.log(`* Connected to ${addr}:${port}`);
}

78
package-lock.json generated Normal file
View File

@ -0,0 +1,78 @@
{
"name": "npm",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "npm",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"tmi.js": "^1.8.2"
}
},
"node_modules/node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
"engines": {
"node": "4.x || >=6.0.0"
}
},
"node_modules/tmi.js": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/tmi.js/-/tmi.js-1.8.2.tgz",
"integrity": "sha512-af1wcF7AQmEB0laylCHswTw/QD9Q51MLZhCNA/V0shn0CyxsBXWPtiSOHdgkGI88ix7moDsr4Mbl6NeVg8rf5Q==",
"dependencies": {
"node-fetch": "^2.6.1",
"ws": "^7.4.3"
},
"engines": {
"node": ">=10.0.0"
}
},
"node_modules/ws": {
"version": "7.4.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz",
"integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
}
},
"dependencies": {
"node-fetch": {
"version": "2.6.1",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"tmi.js": {
"version": "1.8.2",
"resolved": "https://registry.npmjs.org/tmi.js/-/tmi.js-1.8.2.tgz",
"integrity": "sha512-af1wcF7AQmEB0laylCHswTw/QD9Q51MLZhCNA/V0shn0CyxsBXWPtiSOHdgkGI88ix7moDsr4Mbl6NeVg8rf5Q==",
"requires": {
"node-fetch": "^2.6.1",
"ws": "^7.4.3"
}
},
"ws": {
"version": "7.4.5",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.5.tgz",
"integrity": "sha512-xzyu3hFvomRfXKH8vOFMU3OguG6oOvhXMo3xsGy3xWExqaM2dxBbVxuD99O7m3ZUFMvvscsZDqxfgMaRr/Nr1g==",
"requires": {}
}
}
}

18
package.json Normal file
View File

@ -0,0 +1,18 @@
{
"name": "npm",
"version": "1.0.0",
"description": "Highlight Timestamp Marker that listens to messages in a twitch stream chat",
"main": "bot.js",
"scripts": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://git.plutodev.de/DHBW/Twitch_Highlight_Marker"
},
"author": "Patrick Müller, David Huh",
"license": "ISC",
"dependencies": {
"tmi.js": "^1.8.2"
}
}