grammyjs / files

Handle and download received media files.
MIT License
9 stars 0 forks source link

bug: Incorrect file URL #7

Closed yevheniikulisidi closed 8 months ago

yevheniikulisidi commented 8 months ago

When a bot class has an environment variable test:

const bot = new Bot<MyContext>(token, {
  client: { environment: environment === 'production' ? 'prod' : 'test' }
});

Using this code:

const file = await ctx.getFile();
const fileUrl = file.getUrl();

The fileUrl variable is https://api.telegram.org/file/bot<token>/<file_path> It should be https://api.telegram.org/file/bot<token>/test/<file_path>

KnorpelSenf commented 8 months ago

You need to configure the files plugin in the same way you configure the bot.

However, environment is actually not supported by the plugin yet. I will quickly add it.

KnorpelSenf commented 8 months ago

@yevheniikulisidi can you run

npm install github:grammyjs/files#env

and see if that allows you to configure the plugin correctly? Use

hydrateFiles(bot.token, {
  client: { environment: environment === 'production' ? 'prod' : 'test' }
})

and please approve #8 if that fixes your problem.

yevheniikulisidi commented 5 months ago

@KnorpelSenf It's not working!

KnorpelSenf commented 5 months 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 :)