2019-07-10 13:01:02 +02:00
|
|
|
'use strict';
|
|
|
|
|
2020-03-12 16:15:43 +01:00
|
|
|
const { Context } = require('telegraf');
|
2020-03-10 22:10:48 +01:00
|
|
|
|
|
|
|
/** @type { import('../../typings/context').ContextExtensions } */
|
2019-07-10 13:01:02 +02:00
|
|
|
const contextCustomizations = require('../../bot/context');
|
|
|
|
|
2020-05-13 21:23:13 +02:00
|
|
|
/** @param { import('telegraf').Context } ctx */
|
2019-07-10 13:01:02 +02:00
|
|
|
module.exports = (ctx, next) => {
|
|
|
|
if (!ctx.callbackQuery) return next();
|
|
|
|
if (!ctx.callbackQuery.data.startsWith('/')) return next();
|
|
|
|
|
|
|
|
const cbUpdate = {
|
|
|
|
message: {
|
|
|
|
from: ctx.from,
|
|
|
|
chat: ctx.chat,
|
|
|
|
text: ctx.callbackQuery.data,
|
|
|
|
entities: [ { offset: 0, type: 'bot_command' } ],
|
2020-05-13 21:23:13 +02:00
|
|
|
},
|
2019-07-10 13:01:02 +02:00
|
|
|
};
|
|
|
|
|
2020-03-10 22:10:48 +01:00
|
|
|
/** @type { import('../../typings/context').ExtendedContext } */
|
2020-03-12 16:15:43 +01:00
|
|
|
const cbCtx = new Context(cbUpdate, ctx.tg, ctx.options);
|
2019-07-10 13:01:02 +02:00
|
|
|
Object.assign(cbCtx, contextCustomizations);
|
|
|
|
cbCtx.botInfo = ctx.botInfo;
|
|
|
|
|
2021-05-07 22:46:11 +02:00
|
|
|
cbCtx.reply = ctx.editMessageText.bind(ctx);
|
2019-07-10 13:01:02 +02:00
|
|
|
|
|
|
|
return next(cbCtx);
|
|
|
|
};
|