apply maintainer review feedback

This commit is contained in:
Puechberty Arthur
2026-04-11 14:19:08 +02:00
parent 2809e6a77a
commit e8aac8497a
6 changed files with 29 additions and 33 deletions
+6 -6
View File
@@ -11,7 +11,7 @@ JOIN_LEAVE_CHANNEL_ID=
# Redis info # Redis info
# For docker-compose, keep REDIS_HOST=redis # For docker-compose, keep REDIS_HOST=redis
REDIS_HOST=redis REDIS_HOST=redis
REDIS_PASS=change_me_redis_password REDIS_PASS=
# Runtime # Runtime
TZ=UTC TZ=UTC
@@ -22,16 +22,16 @@ XIAO_STATE_DIR=/data
SUCCESS_EMOJI_ID= SUCCESS_EMOJI_ID=
FAILURE_EMOJI_ID= FAILURE_EMOJI_ID=
GOLD_FISH_EMOJI_ID= GOLD_FISH_EMOJI_ID=
GOLD_FISH_EMOJI_NAME=Gold Fish GOLD_FISH_EMOJI_NAME=
MOCKING_EMOJI_ID= MOCKING_EMOJI_ID=
MOCKING_EMOJI_NAME= MOCKING_EMOJI_NAME=
SILVER_FISH_EMOJI_ID= SILVER_FISH_EMOJI_ID=
SILVER_FISH_EMOJI_NAME=Silver Fish SILVER_FISH_EMOJI_NAME=
PORTAL_EMOJI_ID= PORTAL_EMOJI_ID=
PORTAL_EMOJI_NAME=PORTAL PORTAL_EMOJI_NAME=
LOADING_EMOJI_ID= LOADING_EMOJI_ID=
MEGA_EVOLVE_EMOJI_ID= MEGA_EVOLVE_EMOJI_ID=
MEGA_EVOLVE_EMOJI_NAME=MEGA MEGA_EVOLVE_EMOJI_NAME=
NAME_RATER_EMOJI_ID= NAME_RATER_EMOJI_ID=
NAME_RATER_EMOJI_NAME= NAME_RATER_EMOJI_NAME=
@@ -41,7 +41,7 @@ BITLY_KEY=your_bitly_key
CLEVERBOT_KEY=your_cleverbot_key CLEVERBOT_KEY=your_cleverbot_key
GITHUB_ACCESS_TOKEN=your_github_token GITHUB_ACCESS_TOKEN=your_github_token
GOV_KEY=your_nasa_api_key GOV_KEY=your_nasa_api_key
IDIOT_URL=https://en.wikipedia.org/wiki/Idiot IDIOT_URL=
REMOVEBG_KEY=your_removebg_key REMOVEBG_KEY=your_removebg_key
SAUCENAO_KEY=your_saucenao_key SAUCENAO_KEY=your_saucenao_key
THECATAPI_KEY=your_thecatapi_key THECATAPI_KEY=your_thecatapi_key
+4 -4
View File
@@ -27,7 +27,7 @@ I don't really care, but please give credit in some form if you do so. You'll al
> Can I host Xiao myself? > Can I host Xiao myself?
Yes. It is much easier to deploy now, especially with Docker Compose. If you want. Docker Compose makes it simple, or you can do it the old-fashioned way.
> Do I need every API key, emoji ID, etc.? > Do I need every API key, emoji ID, etc.?
@@ -43,8 +43,8 @@ Only if you want to use the DECTalk command.
## Installing ## Installing
There are now two ways to run Xiao: There are two ways to run Xiao:
1. **Quick deploy (recommended):** Docker Compose. 1. **Quick deploy:** Docker Compose.
2. **Manual deploy:** direct Linux setup. 2. **Manual deploy:** direct Linux setup.
### Quick Deploy (Docker Compose) ### Quick Deploy (Docker Compose)
@@ -114,7 +114,7 @@ There are now two ways to run Xiao:
1. Run `npm i -g @dotenvx/dotenvx`. 1. Run `npm i -g @dotenvx/dotenvx`.
2. Run `dotenvx encrypt`. 2. Run `dotenvx encrypt`.
### Run without Docker (Linux) ### Manual Deploy (Linux)
> Install instructions below are for Linux. She should work on Windows, but I can't guarantee anything. > Install instructions below are for Linux. She should work on Windows, but I can't guarantee anything.
+2 -2
View File
@@ -8,7 +8,7 @@ services:
- --appendonly - --appendonly
- "yes" - "yes"
- --requirepass - --requirepass
- ${REDIS_PASS:-change_me_redis_password} - ${REDIS_PASS}
volumes: volumes:
- redis-data:/data - redis-data:/data
@@ -24,7 +24,7 @@ services:
- .env - .env
environment: environment:
REDIS_HOST: ${REDIS_HOST:-redis} REDIS_HOST: ${REDIS_HOST:-redis}
REDIS_PASS: ${REDIS_PASS:-change_me_redis_password} REDIS_PASS: ${REDIS_PASS}
TZ: ${TZ:-UTC} TZ: ${TZ:-UTC}
XIAO_STATE_DIR: ${XIAO_STATE_DIR:-/data} XIAO_STATE_DIR: ${XIAO_STATE_DIR:-/data}
volumes: volumes:
+4 -10
View File
@@ -7,13 +7,7 @@ const Registry = require('./Registry');
const Dispatcher = require('./Dispatcher'); const Dispatcher = require('./Dispatcher');
require('./Extensions'); require('./Extensions');
const STATE_DIR = process.env.XIAO_STATE_DIR const { getStateDir, resolveStatePath } = require('../util/Util');
? path.resolve(process.env.XIAO_STATE_DIR)
: path.join(__dirname, '..');
function resolveStatePath(fileName) {
return path.join(STATE_DIR, fileName);
}
function writeJsonFile(filePath, data) { function writeJsonFile(filePath, data) {
fs.mkdirSync(path.dirname(filePath), { recursive: true }); fs.mkdirSync(path.dirname(filePath), { recursive: true });
@@ -210,7 +204,7 @@ module.exports = class CommandClient extends Client {
} }
text += '\n ]\n}\n'; text += '\n ]\n}\n';
const buf = Buffer.from(text); const buf = Buffer.from(text);
fs.mkdirSync(STATE_DIR, { recursive: true }); fs.mkdirSync(getStateDir(), { recursive: true });
fs.writeFileSync(resolveStatePath('blacklist.json'), buf, { encoding: 'utf8' }); fs.writeFileSync(resolveStatePath('blacklist.json'), buf, { encoding: 'utf8' });
return buf; return buf;
} }
@@ -245,7 +239,7 @@ module.exports = class CommandClient extends Client {
text = text.slice(0, -1); text = text.slice(0, -1);
text += '\n}\n'; text += '\n}\n';
const buf = Buffer.from(text); const buf = Buffer.from(text);
fs.mkdirSync(STATE_DIR, { recursive: true }); fs.mkdirSync(getStateDir(), { recursive: true });
fs.writeFileSync(resolveStatePath('command-leaderboard.json'), buf, { fs.writeFileSync(resolveStatePath('command-leaderboard.json'), buf, {
encoding: 'utf8' encoding: 'utf8'
}); });
@@ -283,7 +277,7 @@ module.exports = class CommandClient extends Client {
text = text.slice(0, -1); text = text.slice(0, -1);
text += '\n}\n'; text += '\n}\n';
const buf = Buffer.from(text); const buf = Buffer.from(text);
fs.mkdirSync(STATE_DIR, { recursive: true }); fs.mkdirSync(getStateDir(), { recursive: true });
fs.writeFileSync(resolveStatePath('command-last-run.json'), buf, { fs.writeFileSync(resolveStatePath('command-last-run.json'), buf, {
encoding: 'utf8' encoding: 'utf8'
}); });
+2 -11
View File
@@ -4,18 +4,9 @@ const fs = require('fs');
const { parser } = require('stream-json'); const { parser } = require('stream-json');
const { pick } = require('stream-json/filters/Pick'); const { pick } = require('stream-json/filters/Pick');
const { streamArray } = require('stream-json/streamers/StreamArray'); const { streamArray } = require('stream-json/streamers/StreamArray');
const path = require('path'); const { checkFileExists, getStateDir, resolveStatePath } = require('../util/Util');
const { checkFileExists } = require('../util/Util');
const rounds = ['jeopardy_round', 'double_jeopardy_round', 'final_jeopardy_round']; const rounds = ['jeopardy_round', 'double_jeopardy_round', 'final_jeopardy_round'];
const STATE_DIR = process.env.XIAO_STATE_DIR
? path.resolve(process.env.XIAO_STATE_DIR)
: path.join(__dirname, '..');
function resolveStatePath(fileName) {
return path.join(STATE_DIR, fileName);
}
module.exports = class JeopardyScrape { module.exports = class JeopardyScrape {
constructor(client) { constructor(client) {
Object.defineProperty(this, 'client', { value: client }); Object.defineProperty(this, 'client', { value: client });
@@ -104,7 +95,7 @@ module.exports = class JeopardyScrape {
gameIDs: this.gameIDs, gameIDs: this.gameIDs,
seasons: this.seasons seasons: this.seasons
})); }));
fs.mkdirSync(STATE_DIR, { recursive: true }); fs.mkdirSync(getStateDir(), { recursive: true });
fs.writeFileSync(resolveStatePath('jeopardy.json'), buf, { encoding: 'utf8' }); fs.writeFileSync(resolveStatePath('jeopardy.json'), buf, { encoding: 'utf8' });
return buf; return buf;
} }
+11
View File
@@ -2,6 +2,7 @@ const { ActionRowBuilder, ButtonBuilder, PermissionFlagsBits, ButtonStyle, Compo
const crypto = require('crypto'); const crypto = require('crypto');
const request = require('node-superfetch'); const request = require('node-superfetch');
const fs = require('fs'); const fs = require('fs');
const path = require('path');
let parseDomain; let parseDomain;
let ParseResultType; let ParseResultType;
import('parse-domain').then(loadedModule => { import('parse-domain').then(loadedModule => {
@@ -203,6 +204,16 @@ module.exports = class Util {
return new Promise(res => fs.access(filepath, fs.constants.F_OK, error => res(!error))); return new Promise(res => fs.access(filepath, fs.constants.F_OK, error => res(!error)));
} }
static getStateDir() {
return process.env.XIAO_STATE_DIR
? path.resolve(process.env.XIAO_STATE_DIR)
: path.join(__dirname, '..');
}
static resolveStatePath(fileName) {
return path.join(Util.getStateDir(), fileName);
}
static stripInvites(str, { guild = true, bot = true, text = '[redacted invite]' } = {}) { static stripInvites(str, { guild = true, bot = true, text = '[redacted invite]' } = {}) {
if (!str) return ''; if (!str) return '';
if (guild) str = str.replace(inviteRegex, text); if (guild) str = str.replace(inviteRegex, text);