Skip to content

Commit

Permalink
support keyboard button in bot lib
Browse files Browse the repository at this point in the history
  • Loading branch information
Leask committed Jul 24, 2024
1 parent 1536576 commit aa6ddda
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/bot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ const getExtra = (ctx, options) => {
message_id: ctx.chatType === PRIVATE ? undefined : ctx.messageId,
}, disable_notification: !!ctx.done.length, ...options || {},
};
resp.reply_markup || (resp.reply_markup = {});
if (options?.buttons?.length) {
resp.reply_markup || (resp.reply_markup = {});
resp.reply_markup.inline_keyboard = options?.buttons.map(button => {
resp.reply_markup.inline_keyboard = options?.buttons?.map(button => {
const id = fakeUuid(button.text);
ctx.session.callback.push({ id, ...button });
return [{
Expand All @@ -156,6 +156,8 @@ const getExtra = (ctx, options) => {
}];
});
}
options?.keyboards?.length
&& (resp.reply_markup.keyboard = options?.keyboards.map(x => [x]));
return resp;
};

Expand Down

0 comments on commit aa6ddda

Please sign in to comment.