mirror of
https://github.com/zhigang1992/telert.git
synced 2026-04-30 20:22:25 +08:00
wip
This commit is contained in:
1
.tool-versions
Normal file
1
.tool-versions
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pnpm 8.3.1
|
||||||
4450
package-lock.json
generated
4450
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -12,5 +12,10 @@
|
|||||||
"start": "wrangler dev",
|
"start": "wrangler dev",
|
||||||
"deploy": "wrangler publish",
|
"deploy": "wrangler publish",
|
||||||
"test": "vitest"
|
"test": "vitest"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@cfworker/web": "^1.12.5",
|
||||||
|
"cfworker-middleware-telegraf": "^2.0.2",
|
||||||
|
"telegraf": "^4.12.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1850
pnpm-lock.yaml
generated
Normal file
1850
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
27
src/index.ts
27
src/index.ts
@@ -7,10 +7,13 @@
|
|||||||
*
|
*
|
||||||
* Learn more at https://developers.cloudflare.com/workers/
|
* Learn more at https://developers.cloudflare.com/workers/
|
||||||
*/
|
*/
|
||||||
|
import {Telegraf} from "telegraf";
|
||||||
|
import {Application, Router} from "@cfworker/web";
|
||||||
|
import createTelegrafMiddleware from 'cfworker-middleware-telegraf'
|
||||||
|
|
||||||
export interface Env {
|
export interface Env {
|
||||||
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
// Example binding to KV. Learn more at https://developers.cloudflare.com/workers/runtime-apis/kv/
|
||||||
// MY_KV_NAMESPACE: KVNamespace;
|
TG_GROUPS: KVNamespace;
|
||||||
//
|
//
|
||||||
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
// Example binding to Durable Object. Learn more at https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
|
||||||
// MY_DURABLE_OBJECT: DurableObjectNamespace;
|
// MY_DURABLE_OBJECT: DurableObjectNamespace;
|
||||||
@@ -22,12 +25,16 @@ export interface Env {
|
|||||||
// MY_SERVICE: Fetcher;
|
// MY_SERVICE: Fetcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
declare global {
|
||||||
async fetch(
|
const BOT_TOKEN: string
|
||||||
request: Request,
|
const SECRET_PATH: string
|
||||||
env: Env,
|
}
|
||||||
ctx: ExecutionContext
|
|
||||||
): Promise<Response> {
|
const bot = new Telegraf(BOT_TOKEN);
|
||||||
return new Response("Hello World!");
|
|
||||||
},
|
// Your code here, but do not `bot.launch()`
|
||||||
};
|
// Do not forget to set environment variables BOT_TOKEN and SECRET_PATH on your worker
|
||||||
|
|
||||||
|
const router = new Router();
|
||||||
|
router.post(`/${SECRET_PATH}`, createTelegrafMiddleware(bot));
|
||||||
|
new Application().use(router.middleware).listen();
|
||||||
|
|||||||
Reference in New Issue
Block a user