From 5c074c33ae3050778b82168b216a0150261c1696 Mon Sep 17 00:00:00 2001 From: petr-shumilov Date: Sun, 11 Feb 2018 14:52:53 +0300 Subject: [PATCH] Add opportunity of custom reply markup for Telegram --- src/services/Telegram.service.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/services/Telegram.service.js b/src/services/Telegram.service.js index a9280d4..11e8a19 100644 --- a/src/services/Telegram.service.js +++ b/src/services/Telegram.service.js @@ -134,6 +134,13 @@ export default class Telegram extends Template { text: ['```'].concat(buttons.map(({ title, value }) => `${value} - ${title}`)).concat('```').join('\n'), })), } + case 'customMarkup': + return { + ...reply, + type: 'customMarkup', + body: _.get(content, 'text'), + keyboard: _.get(content, 'markup'), + } default: throw new BadRequestError('Message type non-supported by Telegram') } @@ -159,6 +166,8 @@ export default class Telegram extends Template { for (const elem of body) { await agent.post(`${url}/sendMessage`, { chat_id: to, text: elem, parse_mode: 'Markdown' }) } + } else if (type === 'customMarkup') { + await agent.post(`${url}/sendMessage`, { chat_id: to, text: body, reply_markup: keyboard, parse_mode: 'Markdown' }) } else { await agent.post(`${url}/${method}`, { chat_id: to, [type]: body }) }