mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-06 19:47:00 +03:00
Added first time submission notifications for discord.
Also updated the downvote notification.
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
"adminUserID": "[the hashed id of the user who can perform admin actions]",
|
"adminUserID": "[the hashed id of the user who can perform admin actions]",
|
||||||
"youtubeAPIKey": null, //get this from Google Cloud Platform [optional]
|
"youtubeAPIKey": null, //get this from Google Cloud Platform [optional]
|
||||||
"discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional]
|
"discordReportChannelWebhookURL": null, //URL from discord if you would like notifications when someone makes a report [optional]
|
||||||
|
"discordFirstTimeSubmissionsWebhookURL": null, //URL from discord if you would like notifications when someone makes a first time submission [optional]
|
||||||
"behindProxy": true,
|
"behindProxy": true,
|
||||||
"db": "./databases/sponsorTimes.db",
|
"db": "./databases/sponsorTimes.db",
|
||||||
"privateDB": "./databases/private.db",
|
"privateDB": "./databases/private.db",
|
||||||
|
|||||||
44
index.js
44
index.js
@@ -221,6 +221,46 @@ app.get('/api/postVideoSponsorTimes', async function (req, res) {
|
|||||||
} else {
|
} else {
|
||||||
res.sendStatus(409);
|
res.sendStatus(409);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//check if they are a first time user
|
||||||
|
//if so, send a notification to discord
|
||||||
|
if (config.youtubeAPIKey !== null && config.discordFirstTimeSubmissionsWebhookURL !== null) {
|
||||||
|
let userSubmissionCountResult = await new Promise((resolve, reject) => {
|
||||||
|
db.prepare("SELECT count(*) as submissionCount FROM sponsorTimes WHERE userID = ?").get(userID, (err, row) => resolve({err, row}));
|
||||||
|
});
|
||||||
|
|
||||||
|
// If it is a first time submission
|
||||||
|
if (userSubmissionCountResult.row.submissionCount === 0) {
|
||||||
|
YouTubeAPI.videos.list({
|
||||||
|
part: "snippet",
|
||||||
|
id: videoID
|
||||||
|
}, function (err, data) {
|
||||||
|
if (err) {
|
||||||
|
console.log(err);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
request.post(config.discordFirstTimeSubmissionsWebhookURL, {
|
||||||
|
json: {
|
||||||
|
"embeds": [{
|
||||||
|
"title": data.items[0].snippet.title,
|
||||||
|
"url": "https://www.youtube.com/watch?v=" + videoID + "&t=" + (startTime.toFixed(0) - 2),
|
||||||
|
"description": "Submission ID: " + UUID +
|
||||||
|
"\n\nTimestamp: " +
|
||||||
|
getFormattedTime(startTime) + " to " + getFormattedTime(endTime),
|
||||||
|
"color": 10813440,
|
||||||
|
"author": {
|
||||||
|
"name": userID
|
||||||
|
},
|
||||||
|
"thumbnail": {
|
||||||
|
"url": data.items[0].snippet.thumbnails.maxres.url,
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -334,9 +374,9 @@ app.get('/api/voteOnSponsorTime', function (req, res) {
|
|||||||
json: {
|
json: {
|
||||||
"embeds": [{
|
"embeds": [{
|
||||||
"title": data.items[0].snippet.title,
|
"title": data.items[0].snippet.title,
|
||||||
"url": "https://youtube.com/watch?v=" + submissionInfoResult.row.videoID + "&t=" + submissionInfoResult.row.startTime.toFixed(0),
|
"url": "https://www.youtube.com/watch?v=" + submissionInfoResult.row.videoID + "&t=" + (submissionInfoResult.row.startTime.toFixed(0) - 2),
|
||||||
"description": "**" + row.votes + " Votes | " + row.views + " Views**\n\nSubmission ID: " + UUID +
|
"description": "**" + row.votes + " Votes | " + row.views + " Views**\n\nSubmission ID: " + UUID +
|
||||||
"\n\nSubmission by " + submissionInfoResult.row.userID + "\n\nTimestamp: " +
|
"\n\nSubmitted by: " + submissionInfoResult.row.userID + "\n\nTimestamp: " +
|
||||||
getFormattedTime(submissionInfoResult.row.startTime) + " to " + getFormattedTime(submissionInfoResult.row.endTime),
|
getFormattedTime(submissionInfoResult.row.startTime) + " to " + getFormattedTime(submissionInfoResult.row.endTime),
|
||||||
"color": 10813440,
|
"color": 10813440,
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user