(error) TypeError: The "chunk" argument must be one of type string or Buffer. Received type object
at new n2 (worker.js:16656:23)
at worker.js:17181:95
at A.write (worker.js:17182:10)
at A.end (worker.js:17216:144)
at s.addPart (worker.js:20412:73)
at S (worker.js:20325:21)
at async worker.js:20313:22
at async Promise.all (index 2)
at async _ (worker.js:20318:16)
at async s.callApi (worker.js:20362:30)
import { Telegraf, Markup } from 'telegraf';
import { Application, Router } from '@cfworker/web';
import createTelegrafMiddware from 'cfworker-middware-telegraf';
import { DEFAULT_CORS_HEADERS } from './utils';
const bot = new Telegraf(TELEGRAM_API_TOKEN);
//... other commands here
bot.command('caption', (ctx) => {
return ctx.replyWithPhoto({ url: 'https://picsum.photos/200/300/?random' },
{
caption: 'Caption',
parse_mode: 'Markdown',
...Markup.inlineKeyboard([
Markup.button.callback('Plain', 'plain'),
Markup.button.callback('Italic', 'italic')
])
}
)
});
const router = new Router();
// Simple CORS middleware.
const cors = async ({ res }, next) => {
for (const HEADER_KEY in DEFAULT_CORS_HEADERS) {
res.headers.set(HEADER_KEY, DEFAULT_CORS_HEADERS[HEADER_KEY]);
}
await next();
};
router.post(`/${TELEGRAM_SECRET_PATH}`, createTelegrafMiddware(bot));
new Application().use(cors).use(router.middleware).listen();