From b18c10fa93b74408361f7c01aa991580ee15fb19 Mon Sep 17 00:00:00 2001 From: mullwar Date: Fri, 28 Apr 2017 21:08:36 +0300 Subject: [PATCH] No "switch_pm_text" & "switch_pm_parameter" #53 --- README.md | 2 +- lib/methods.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1da44c8..228fba0 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ Creates `InlineKeyboardButton` button object. Creates inlineKeyboard object for normal bot messages. -##### `answerList(, {nextOffset, cacheTime, personal})` +##### `answerList(, {nextOffset, cacheTime, personal, pmText, pmParameter})` Creates `answerInlineQuery` answer list object. diff --git a/lib/methods.js b/lib/methods.js index f381ce4..10d221a 100644 --- a/lib/methods.js +++ b/lib/methods.js @@ -181,13 +181,21 @@ const methods = { answerInlineQuery: { short: 'answerQuery', arguments: answers => { - return { + + const data = { inline_query_id: answers.id, results: answers.results(), next_offset: answers.nextOffset, is_personal: answers.personal, cache_time: answers.cacheTime }; + + if (answers.pmText && answers.pmParameter) { + data.switch_pm_text = answers.pmText; + data.switch_pm_parameter = answers.pmParameter; + } + + return data; } }, @@ -304,6 +312,8 @@ class AnswerList { this.cacheTime = Number(opt.cacheTime) || 300; this.nextOffset = opt.nextOffset === undefined ? null : opt.nextOffset; this.personal = opt.personal === undefined ? false : opt.personal; + this.pmText = opt.pmText; + this.pmParameter = opt.pmParameter; this.list = []; }