diff --git a/adapters/telegram/package.json b/adapters/telegram/package.json index 877d4a7c..0117307b 100644 --- a/adapters/telegram/package.json +++ b/adapters/telegram/package.json @@ -33,6 +33,7 @@ "@satorijs/satori": "^2.5.4" }, "dependencies": { + "file-type": "^16.5.4", "form-data": "^4.0.0" } } diff --git a/adapters/telegram/src/bot.ts b/adapters/telegram/src/bot.ts index 8454d5f9..2e9305a3 100644 --- a/adapters/telegram/src/bot.ts +++ b/adapters/telegram/src/bot.ts @@ -4,6 +4,7 @@ import { adaptAuthorMeta, adaptGuildMember, adaptMessageMeta, adaptUser } from ' import { TelegramMessageEncoder } from './message' import { HttpServer } from './server' import { HttpPolling } from './polling' +import FileType from 'file-type' const logger = new Logger('telegram') @@ -270,7 +271,10 @@ export class TelegramBot exte if (this.server) { return { url: `${this.server}/${filePath}` } } - const { mime, data } = await this.$getFile(filePath) + let { mime, data } = await this.$getFile(filePath) + if (mime === 'application/octet-stream') { + mime = await FileType.fromBuffer(data)?.mime + } const base64 = `data:${mime};base64,` + arrayBufferToBase64(data) return { url: base64 } }