feat: telegram Set manually to avoid implicit call in (#442)

This commit is contained in:
Dream Hunter
2024-09-09 20:59:12 +08:00
committed by GitHub
parent de80857e2c
commit 5ece49a576
12 changed files with 42 additions and 6 deletions

View File

@@ -2,6 +2,26 @@ import { Context } from "hono";
import { createMimeMessage } from "mimetext";
import { HonoCustomType, UserRole } from "./types";
export const getJsonObjectValue = <T = any>(
value: string | any
): T | null => {
if (value == undefined || value == null) {
return null;
}
if (typeof value === "object") {
return value as T;
}
if (typeof value !== "string") {
return null;
}
try {
return JSON.parse(value) as T;
} catch (e) {
console.error(`GetJsonValue: Failed to parse ${value}`, e);
}
return null;
}
export const getJsonSetting = async <T = any>(
c: Context<HonoCustomType>, key: string
): Promise<T | null> => {