grammyjs / website

The grammY documentation website.
https://grammy.dev
MIT License
46 stars 105 forks source link

The hosting does not work CFW #1148

Open snagovskiy opened 1 week ago

snagovskiy commented 1 week ago
/**
 * Welcome to Cloudflare Workers! This is your first worker.
 *
 * - Run `npm run dev` in your terminal to start a development server
 * - Open a browser tab at http://localhost:8787/ to see your worker in action
 * - Run `npm run deploy` to publish your worker
 *
 * Learn more at https://developers.cloudflare.com/workers/
 */

import { Bot, Context, webhookCallback } from "grammy";

export interface Env {

  BOT_INFO: string;
  BOT_TOKEN: string;
}

export default {
  async fetch(
    request: Request,
    env: Env,
    ctx: ExecutionContext,
  ): Promise<Response> {
    const bot = new Bot(env.BOT_TOKEN, { botInfo: JSON.parse(env.BOT_INFO) });

    bot.command("start", async (ctx: Context) => {
      await ctx.reply("Привет, мир!");
    });

    return webhookCallback(bot, "cloudflare-mod")(request);
  },
};

this code does not work version: wangler 3.86.0

KnorpelSenf commented 1 week ago

Remember that when you say it “doesn't work”, we cannot login to your computer and figure out what's wrong. You need to explain what you are doing, what you are expecting to happen, and what is actually happening. If there's an error, share the full error message, too :)

snagovskiy commented 1 week ago
C:\Users\Alexander\Documents\testbot>npm run deploy

> testbot@0.0.0 deploy
> wrangler deploy

 ⛅️ wrangler 3.86.1
-------------------

X [ERROR] Build failed with 1 error:

  X [ERROR] Unexpected "interface"

      src/index.js:13:7:
        13 │ export interface Env {
           ╵        ~~~~~~~~~

Remember that when you say it “doesn't work”, we cannot login to your computer and figure out what's wrong. You need to explain what you are doing, what you are expecting to happen, and what is actually happening. If there's an error, share the full error message, too :)

KnorpelSenf commented 1 week ago

You're using TypeScript code but you didn't compile it … I have a feeling that you should maybe run a getting started tutorial and learn a bit more about programming before trying to use CFW for deploying your bot