Skip to content
This repository has been archived by the owner on Nov 26, 2019. It is now read-only.

Add opportunity of custom reply markup for Telegram #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/services/Telegram.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
Expand All @@ -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 })
}
Expand Down