Emojis!
This commit is contained in:
parent
2d1df01fcf
commit
5c0b892e22
3 changed files with 38 additions and 23 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -134,3 +134,4 @@ dist
|
||||||
static/cached
|
static/cached
|
||||||
cached
|
cached
|
||||||
config
|
config
|
||||||
|
emojis
|
8
index.js
8
index.js
|
@ -39,14 +39,10 @@ app.use("/cached", express.static(cachePath))
|
||||||
app.use("/imgs", express.static(path.join(assetPath, "Images")))
|
app.use("/imgs", express.static(path.join(assetPath, "Images")))
|
||||||
app.use("/snds", express.static(path.join(assetPath, "Sounds")))
|
app.use("/snds", express.static(path.join(assetPath, "Sounds")))
|
||||||
|
|
||||||
|
app.use("/emojis", express.static(path.join(cachePath, "emojis")))
|
||||||
|
|
||||||
if (!fs.existsSync(cachePath)) {
|
if (!fs.existsSync(cachePath)) {
|
||||||
fs.mkdirSync(cachePath)
|
fs.mkdirSync(cachePath)
|
||||||
} else {
|
|
||||||
var files = fs.readdirSync(cachePath)
|
|
||||||
for (let index = 0; index < files.length; index++) {
|
|
||||||
const file = files[index];
|
|
||||||
fs.rmSync(path.join(cachePath, file))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get("/discHTML", (req, res) => {
|
app.get("/discHTML", (req, res) => {
|
||||||
|
|
|
@ -49,18 +49,6 @@ function converter(html) {
|
||||||
|
|
||||||
var statusText = ""
|
var statusText = ""
|
||||||
|
|
||||||
if (lanyardData) {
|
|
||||||
var statusData = constants.discStatuses[lanyardData.discord_status]
|
|
||||||
var username = lanyardData.discord_user.username
|
|
||||||
|
|
||||||
if (lanyardData.activities[0] && lanyardData.activities[0].type == 4) {
|
|
||||||
var statusText = `<hr/><p>${lanyardData.activities[0].state}</p>`
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
var statusData = constants.discStatuses.offline
|
|
||||||
var username = "bingus_violet"
|
|
||||||
}
|
|
||||||
|
|
||||||
var bnchName = "Beta"
|
var bnchName = "Beta"
|
||||||
var bnchSub = "beta."
|
var bnchSub = "beta."
|
||||||
|
|
||||||
|
@ -79,12 +67,27 @@ function converter(html) {
|
||||||
"QUOTE_COUNT": quotes.length,
|
"QUOTE_COUNT": quotes.length,
|
||||||
"RANDOM_TITLE": titles[Math.floor(Math.random() * titles.length)],
|
"RANDOM_TITLE": titles[Math.floor(Math.random() * titles.length)],
|
||||||
"DISCORD_STATUS":
|
"DISCORD_STATUS":
|
||||||
`<span style="color: ${statusData.color};" class="statusColor">${statusData.text}</span>` +
|
`<span style="color: ${constants.discStatuses[lanyardData.discord_status].color};" class="statusColor">${constants.discStatuses[lanyardData.discord_status].text}</span>` +
|
||||||
`<style>.pfp { border-color: ${statusData.color} }</style>`,
|
`<style>.pfp { border-color: ${constants.discStatuses[lanyardData.discord_status].color} }</style>`,
|
||||||
"UPTIME": uptime,
|
"UPTIME": uptime,
|
||||||
"TOPBAR": `<div id="topbar"><h3><a href="/socials">Socials</a></h3></div>`,
|
"TOPBAR": `<div id="topbar"><h3><a href="/socials">Socials</a></h3></div>`,
|
||||||
"DISCORD_USER": username,
|
"CUSTOM_STATUS": () => {
|
||||||
"CUSTOM_STATUS": statusText,
|
if (lanyardData && lanyardData.activities[0] && lanyardData.activities[0].type == 4) {
|
||||||
|
var status = lanyardData.activities[0]
|
||||||
|
var addedHTML = "<hr/><p>"
|
||||||
|
if (status.emoji) {
|
||||||
|
if (status.emoji.id) {
|
||||||
|
addedHTML += `<img src="/emojis/${status.emoji.id}" style="width: 48px; vertical-align: middle;"/>`
|
||||||
|
} else {
|
||||||
|
addedHTML += status.emoji.name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
addedHTML += status.state
|
||||||
|
addedHTML += "</p>"
|
||||||
|
return addedHTML
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
},
|
||||||
"SELECTED_VIDEO": () => {
|
"SELECTED_VIDEO": () => {
|
||||||
if (config.dailyVideoURL) {
|
if (config.dailyVideoURL) {
|
||||||
return `<h2><hr/>Random video!</h2><p>I would call it random <em>daily</em> video but its not at all daily...</p>
|
return `<h2><hr/>Random video!</h2><p>I would call it random <em>daily</em> video but its not at all daily...</p>
|
||||||
|
@ -309,6 +312,21 @@ function socketeer() {
|
||||||
} else if (data.op == 0) {
|
} else if (data.op == 0) {
|
||||||
lanyardData = data.d
|
lanyardData = data.d
|
||||||
lastLanyardUpdate = Date.now()
|
lastLanyardUpdate = Date.now()
|
||||||
|
|
||||||
|
for (var i = 0; i < lanyardData.activities.length; i++) {
|
||||||
|
var activity = lanyardData.activities[i]
|
||||||
|
if (activity.type == 4 && activity.emoji) {
|
||||||
|
|
||||||
|
if (activity.emoji.id) {
|
||||||
|
if (activity.emoji.animated) {
|
||||||
|
var emoji = Buffer.from(await (await fetch(`https://cdn.discordapp.com/emojis/${activity.emoji.id}.gif?quality=lossless`)).arrayBuffer())
|
||||||
|
} else {
|
||||||
|
var emoji = Buffer.from(await (await fetch(`https://cdn.discordapp.com/emojis/${activity.emoji.id}.png?quality=lossless`)).arrayBuffer())
|
||||||
|
}
|
||||||
|
fs.writeFileSync(path.join(__dirname, "cached/emojis", activity.emoji.id), emoji)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (data.op == 4) {
|
} else if (data.op == 4) {
|
||||||
globalSpins = data.spins
|
globalSpins = data.spins
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue