Enhance verification module with improved command handling and localization
- Updated the verification command to utilize a new `ephemeral` utility for consistent ephemeral message replies. - Refactored the `buildVerificationPanel` function to include localization support for panel titles and descriptions. - Added permission checks to ensure the bot can post in the designated verification channel. - Introduced a new verification queue in the queue management system for better handling of verification tasks. - Updated localization files to include new keys for verification-related messages in both English and German.
This commit is contained in:
32
apps/webui/src/lib/captcha.ts
Normal file
32
apps/webui/src/lib/captcha.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { createHash } from 'node:crypto';
|
||||
import { redis } from './redis';
|
||||
|
||||
const CAPTCHA_PREFIX = 'verify:captcha:';
|
||||
|
||||
export type CaptchaChallenge = {
|
||||
token: string;
|
||||
guildId: string;
|
||||
userId: string;
|
||||
question: string;
|
||||
answerHash: string;
|
||||
};
|
||||
|
||||
export async function getCaptchaChallenge(token: string): Promise<CaptchaChallenge | null> {
|
||||
const raw = await redis.get(`${CAPTCHA_PREFIX}${token}`);
|
||||
if (!raw) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return JSON.parse(raw) as CaptchaChallenge;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteCaptchaChallenge(token: string): Promise<void> {
|
||||
await redis.del(`${CAPTCHA_PREFIX}${token}`);
|
||||
}
|
||||
|
||||
export function hashCaptchaAnswer(answer: string): string {
|
||||
return createHash('sha256').update(answer.trim()).digest('hex');
|
||||
}
|
||||
Reference in New Issue
Block a user