use klipy instead of tenor

This commit is contained in:
2026-02-01 18:31:53 +01:00
parent 0c0efa645a
commit 79efc479f4
17 changed files with 1062 additions and 27 deletions

View File

@@ -244,6 +244,7 @@ export function createApiRoutes(client: BotClient) {
free_will_chance: 2,
memory_chance: 30,
mention_probability: 0,
gif_search_enabled: 0,
});
}
@@ -260,12 +261,30 @@ export function createApiRoutes(client: BotClient) {
return c.json({ error: "Access denied" }, 403);
}
const body = await c.req.json<{
const contentType = c.req.header("content-type");
let body: {
active_personality_id?: string | null;
free_will_chance?: number;
memory_chance?: number;
mention_probability?: number;
}>();
gif_search_enabled?: boolean | string;
};
if (contentType?.includes("application/x-www-form-urlencoded")) {
const form = await c.req.parseBody();
body = {
active_personality_id: form.active_personality_id as string || null,
free_will_chance: form.free_will_chance ? parseInt(form.free_will_chance as string) : undefined,
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",
};
} else {
body = await c.req.json();
}
// Convert gif_search_enabled to integer for SQLite
const gifSearchEnabled = body.gif_search_enabled ? 1 : 0;
// Upsert options
const existing = await db
@@ -277,13 +296,21 @@ export function createApiRoutes(client: BotClient) {
if (existing.length === 0) {
await db.insert(botOptions).values({
guild_id: guildId,
...body,
active_personality_id: body.active_personality_id,
free_will_chance: body.free_will_chance,
memory_chance: body.memory_chance,
mention_probability: body.mention_probability,
gif_search_enabled: gifSearchEnabled,
});
} else {
await db
.update(botOptions)
.set({
...body,
active_personality_id: body.active_personality_id,
free_will_chance: body.free_will_chance,
memory_chance: body.memory_chance,
mention_probability: body.mention_probability,
gif_search_enabled: gifSearchEnabled,
updated_at: new Date().toISOString(),
})
.where(eq(botOptions.guild_id, guildId));