feat: telegram bot TelegramSettings && webhook (#244)

* feat: telegram bot TelegramSettings

* feat: webhook
This commit is contained in:
Dream Hunter
2024-05-18 14:02:18 +08:00
committed by GitHub
parent 53a06fc9d6
commit ca00a877ad
32 changed files with 777 additions and 112 deletions

34
worker/src/commom_api.ts Normal file
View File

@@ -0,0 +1,34 @@
import { Hono } from 'hono'
// @ts-ignore
import { getDomains, getPasswords, getBooleanValue } from './utils';
import { CONSTANTS } from './constants';
import { Bindings } from './types';
const api = new Hono<{ Bindings: Bindings }>
api.get('/open_api/settings', async (c) => {
// check header x-custom-auth
let needAuth = false;
const passwords = getPasswords(c);
if (passwords && passwords.length > 0) {
const auth = c.req.raw.headers.get("x-custom-auth");
needAuth = !passwords.includes(auth);
}
return c.json({
"prefix": c.env.PREFIX,
"domains": getDomains(c),
"needAuth": needAuth,
"adminContact": c.env.ADMIN_CONTACT,
"enableUserCreateEmail": getBooleanValue(c.env.ENABLE_USER_CREATE_EMAIL),
"enableUserDeleteEmail": getBooleanValue(c.env.ENABLE_USER_DELETE_EMAIL),
"enableAutoReply": getBooleanValue(c.env.ENABLE_AUTO_REPLY),
"enableIndexAbout": getBooleanValue(c.env.ENABLE_INDEX_ABOUT),
"copyright": c.env.COPYRIGHT,
"cfTurnstileSiteKey": c.env.CF_TURNSTILE_SITE_KEY,
"enableWebhook": getBooleanValue(c.env.ENABLE_WEBHOOK),
"version": CONSTANTS.VERSION,
});
})
export { api }