1.0.1 • Published 1 year ago

worker-td-api v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

worker-td-api

telegram api for cloudflare workers

Useage

  • npm create cloudflare@latest
  • npx wrangler login
  • npx wrangler secret put SECRET_TELEGRAM_API_TOKEN, set it to your telegram bot token that you got from @BotFather
  • npx wrangler deploy
  • Open this url in your browser to set your webhook https://api.telegram.org/bot${SECRET_TELEGRAM_API_TOKEN}/setWebhook?url=${YOUR_WORKER_URL}/${SECRET_TELEGRAM_API_TOKEN}

example

import TDBot from "worker-td-api";
export default {
  async fetch(request, env): Promise<Response> {
    const bot = new TDBot(env.SECRET_TELEGRAM_API_TOKEN);
    await bot
      .onMatch(/\?|?/, async (ctx) => {
        ctx.reply("谁问你了?");
      })
      .launch(request.clone());
  },
} satisfies ExportedHandler<Env>;
1.0.1

1 year ago

1.0.0

1 year ago