✨ Added request for database.
This commit is contained in:
parent
bb7c356b39
commit
f5a43c897c
33
bot.js
33
bot.js
|
@ -1,6 +1,8 @@
|
|||
require('dotenv').config();
|
||||
const tmi = require('tmi.js');
|
||||
const https = require('https');
|
||||
const request = require('request');
|
||||
|
||||
const options = {
|
||||
hostname: 'api.twitch.tv',
|
||||
port: 443,
|
||||
|
@ -13,7 +15,6 @@ const options = {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Define configuration options
|
||||
const opts = {
|
||||
identity: {
|
||||
|
@ -132,7 +133,11 @@ function onMessageHandler(target, context, msg, self) {
|
|||
|
||||
username = context["username"];
|
||||
|
||||
const json_for_sql = {
|
||||
// Post request to database
|
||||
request.post(
|
||||
'https://api.plutodev.de/twitch-highlight-marker/addHighlight',
|
||||
{
|
||||
json: {
|
||||
access_key: process.env.ACCESS_KEY,
|
||||
streamer: streamer,
|
||||
stream_id: stream_id,
|
||||
|
@ -140,13 +145,21 @@ function onMessageHandler(target, context, msg, self) {
|
|||
timestamp: timestamp,
|
||||
description: description,
|
||||
username: username
|
||||
};
|
||||
|
||||
// TODO send API request to database
|
||||
|
||||
}
|
||||
},
|
||||
function (error, response, body) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
// ENGLISH: client.say(target, `Mark has been tracked for the next highlight video. Thank you for your submission ${username}! `);
|
||||
client.say(target, `Die Markierung wurde für das nächste Highlight Video gespeichert. Danke für deine Hilfe ${username}!`);
|
||||
});
|
||||
console.log(body);
|
||||
} else {
|
||||
client.say(target, `Leider ist etwas schief gelaufen. Versuch es bitte später erneut.`);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
})
|
||||
req.end();
|
||||
} else {
|
||||
|
@ -158,13 +171,13 @@ function onMessageHandler(target, context, msg, self) {
|
|||
// readable decides if the words "hours", "minutes" and "seconds" should be added
|
||||
function getTimeInFormat(timeInMillis, readable) {
|
||||
let hours = Math.floor(timeInMillis / 1000 / 60 / 60);
|
||||
timeInMillis -= hours * 1000 * 60 * 60
|
||||
timeInMillis -= hours * 1000 * 60 * 60;
|
||||
let minutes = Math.floor((timeInMillis) / 1000 / 60);
|
||||
timeInMillis -= minutes * 1000 * 60
|
||||
timeInMillis -= minutes * 1000 * 60;
|
||||
let seconds = Math.floor((timeInMillis) / 1000);
|
||||
|
||||
if (readable) {
|
||||
return hours + " Stunde/n " + minutes + " Minute/n " + seconds + " Sekunde/n"
|
||||
return hours + " Stunde/n " + minutes + " Minute/n " + seconds + " Sekunde/n";
|
||||
} else {
|
||||
return hours + ":" + minutes + ":" + seconds;
|
||||
}
|
||||
|
|
746
package-lock.json
generated
746
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
@ -16,5 +16,8 @@
|
|||
"dotenv": "^8.2.0",
|
||||
"tmi.js": "^1.8.2",
|
||||
"twitch-js": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"request": "^2.88.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user