Compare commits

..

No commits in common. "097d186f583f20ba47de565e796242856abaec01" and "6926e6c7e51e9aa80da9b30a6a71b83bbcdbaa00" have entirely different histories.

5 changed files with 7 additions and 7 deletions

View File

@ -2,4 +2,5 @@ FROM node:latest
ADD . /app ADD . /app
WORKDIR /app WORKDIR /app
RUN npm ci RUN npm ci
VOLUME /app/data
CMD ["node", "main.js"] CMD ["node", "main.js"]

View File

@ -13,4 +13,6 @@ module.exports = {
porn_channel: "835734868427669574", porn_channel: "835734868427669574",
data_dir: process.cwd() + "/data/", data_dir: process.cwd() + "/data/",
web_hostname: "ldb.owo69.me", web_hostname: "ldb.owo69.me",
avatar_cache_dir: "/srv/www/ldb/avatars/",
avatar_cache_url: `https://${this.web_hostname}/avatars/`,
} }

View File

@ -3,4 +3,4 @@ cd `dirname "$0"`
docker stop ldb docker stop ldb
docker rm ldb docker rm ldb
docker build --no-cache -t ledlamp/lampdiscordbot . docker build --no-cache -t ledlamp/lampdiscordbot .
docker run -d --name ldb --restart=unless-stopped -p 127.0.0.1:9251:9251 --env-file=secrets.env -v /srv/ldb/data:/app/data -v /srv/www/ldb/:/srv/www/ldb/ ledlamp/lampdiscordbot docker run -d --name ldb --restart=unless-stopped -p 127.0.0.1:9251:9251 --env-file=secrets.env -v /srv/www/ldb/:/srv/www/ldb/ ledlamp/lampdiscordbot

View File

@ -29,6 +29,6 @@ client.on("guildMemberRemove", member => {
require('./commands.js'); require('./commands.js');
require('./colors.js'); require('./colors.js');
global.app = require('./www.js');
require('./pinboard.js'); require('./pinboard.js');
global.app = require('./www.js');
require('./pixiv-embedder.js'); require('./pixiv-embedder.js');

View File

@ -1,6 +1,5 @@
var fs = require("fs"); var fs = require("fs");
var fetch = require("node-fetch"); var fetch = require("node-fetch");
client.on("messageReactionAdd", async (reaction, user) => { client.on("messageReactionAdd", async (reaction, user) => {
if (reaction.emoji.name == '📍' || reaction.emoji.name == '📌') { if (reaction.emoji.name == '📍' || reaction.emoji.name == '📌') {
if (!reaction.message.guild) return; if (!reaction.message.guild) return;
@ -30,7 +29,7 @@ client.on("messageReactionAdd", async (reaction, user) => {
var avatarURL = reaction.message.author.avatarURL({dynamic: true}); var avatarURL = reaction.message.author.avatarURL({dynamic: true});
if (avatarURL) { if (avatarURL) {
let afn = avatarURL.split('/').pop(); let afn = avatarURL.split('/').pop();
let lapath = config.data_dir + "avatars/" + afn; let lapath = config.avatar_cache_dir + afn;
if (!fs.existsSync(lapath)) { if (!fs.existsSync(lapath)) {
try { try {
(await fetch(avatarURL)).body.pipe(fs.createWriteStream(lapath)); (await fetch(avatarURL)).body.pipe(fs.createWriteStream(lapath));
@ -38,7 +37,7 @@ client.on("messageReactionAdd", async (reaction, user) => {
console.error("avatar download", error.message); console.error("avatar download", error.message);
} }
} }
avatarURL = `https://${config.web_hostname}/avatars/${afn}` avatarURL = config.avatar_cache_url + afn;
} else avatarURL = reaction.message.author.defaultAvatarURL; } else avatarURL = reaction.message.author.defaultAvatarURL;
let imageCandidate = reaction.message.attachments.find(a => [".png",".jpg",".jpeg",".webp",".gif"].some(e => a.url.toLowerCase().endsWith(e))); let imageCandidate = reaction.message.attachments.find(a => [".png",".jpg",".jpeg",".webp",".gif"].some(e => a.url.toLowerCase().endsWith(e)));
@ -56,5 +55,3 @@ client.on("messageReactionAdd", async (reaction, user) => {
(await client.channels.fetch(config.archive_channel))?.send({content: `https://discord.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, embeds:[embed]}); (await client.channels.fetch(config.archive_channel))?.send({content: `https://discord.com/channels/${reaction.message.guild.id}/${reaction.message.channel.id}/${reaction.message.id}`, embeds:[embed]});
} }
}); });
app.use("/avatars/", require("express").static(config.data_dir + "avatars/"));