joel image handler

This commit is contained in:
2026-02-02 12:18:44 +01:00
parent 09143a0638
commit a4300f8eec
14 changed files with 452 additions and 5 deletions

View File

@@ -245,6 +245,7 @@ export function createApiRoutes(client: BotClient) {
memory_chance: 30,
mention_probability: 0,
gif_search_enabled: 0,
image_gen_enabled: 0,
});
}
@@ -268,6 +269,7 @@ export function createApiRoutes(client: BotClient) {
memory_chance?: number;
mention_probability?: number;
gif_search_enabled?: boolean | string;
image_gen_enabled?: boolean | string;
};
if (contentType?.includes("application/x-www-form-urlencoded")) {
@@ -278,13 +280,15 @@ export function createApiRoutes(client: BotClient) {
memory_chance: form.memory_chance ? parseInt(form.memory_chance as string) : undefined,
mention_probability: form.mention_probability ? parseInt(form.mention_probability as string) : undefined,
gif_search_enabled: form.gif_search_enabled === "on" || form.gif_search_enabled === "true",
image_gen_enabled: form.image_gen_enabled === "on" || form.image_gen_enabled === "true",
};
} else {
body = await c.req.json();
}
// Convert gif_search_enabled to integer for SQLite
// Convert boolean options to integer for SQLite
const gifSearchEnabled = body.gif_search_enabled ? 1 : 0;
const imageGenEnabled = body.image_gen_enabled ? 1 : 0;
// Upsert options
const existing = await db
@@ -301,6 +305,7 @@ export function createApiRoutes(client: BotClient) {
memory_chance: body.memory_chance,
mention_probability: body.mention_probability,
gif_search_enabled: gifSearchEnabled,
image_gen_enabled: imageGenEnabled,
});
} else {
await db
@@ -311,6 +316,7 @@ export function createApiRoutes(client: BotClient) {
memory_chance: body.memory_chance,
mention_probability: body.mention_probability,
gif_search_enabled: gifSearchEnabled,
image_gen_enabled: imageGenEnabled,
updated_at: new Date().toISOString(),
})
.where(eq(botOptions.guild_id, guildId));

View File

@@ -27,6 +27,7 @@ interface BotOptions {
memory_chance: number | null;
mention_probability: number | null;
gif_search_enabled: number | null;
image_gen_enabled: number | null;
}
export function dashboardPage(user: User, guilds: Guild[]): string {
@@ -262,6 +263,16 @@ The user's name is {author}. Insult {author} by name.
<p style="color: #666; font-size: 12px; margin-top: 4px;">Allow Joel to search for and send funny GIFs in his responses. Powered by Klipy.</p>
</div>
<div class="form-group">
<label style="display: flex; align-items: center; gap: 10px; cursor: pointer;">
<input type="checkbox" id="image_gen_enabled" name="image_gen_enabled"
${options.image_gen_enabled ? 'checked' : ''}
style="width: 20px; height: 20px; cursor: pointer;">
<span>🎨 Enable Image Generation (NSFW)</span>
</label>
<p style="color: #666; font-size: 12px; margin-top: 4px;">Allow Joel to generate images including NSFW content. Powered by FLUX via Replicate.</p>
</div>
<button type="submit" class="btn">Save Options</button>
</form>
</div>