mirror of
https://github.com/zhigang1992/telert.git
synced 2026-01-12 22:42:11 +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",
|
||||
"deploy": "wrangler publish",
|
||||
"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/
|
||||
*/
|
||||
import {Telegraf} from "telegraf";
|
||||
import {Application, Router} from "@cfworker/web";
|
||||
import createTelegrafMiddleware from 'cfworker-middleware-telegraf'
|
||||
|
||||
export interface Env {
|
||||
// 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/
|
||||
// MY_DURABLE_OBJECT: DurableObjectNamespace;
|
||||
@@ -22,12 +25,16 @@ export interface Env {
|
||||
// MY_SERVICE: Fetcher;
|
||||
}
|
||||
|
||||
export default {
|
||||
async fetch(
|
||||
request: Request,
|
||||
env: Env,
|
||||
ctx: ExecutionContext
|
||||
): Promise<Response> {
|
||||
return new Response("Hello World!");
|
||||
},
|
||||
};
|
||||
declare global {
|
||||
const BOT_TOKEN: string
|
||||
const SECRET_PATH: string
|
||||
}
|
||||
|
||||
const bot = new Telegraf(BOT_TOKEN);
|
||||
|
||||
// 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