If no query is entered, just return an empty result.

parent 4cd67ceb
......@@ -37,23 +37,22 @@ class InlinequeryCommand extends SystemCommand
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
if ($query === '') {
return Request::emptyResponse();
}
$data['inline_query_id'] = $inline_query->getId();
$data = ['inline_query_id' => $inline_query->getId()];
$results = [];
if ($query !== '') {
$articles = [
['id' => '001', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query , 'input_message_content' => new InputTextMessageContent([ 'message_text' => ' ' . $query ])],
['id' => '002', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query , 'input_message_content' => new InputTextMessageContent([ 'message_text' => ' ' . $query ])],
['id' => '003', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query , 'input_message_content' => new InputTextMessageContent([ 'message_text' => ' ' . $query ])],
['id' => '001', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query, 'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])],
['id' => '002', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query, 'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])],
['id' => '003', 'title' => 'https://core.telegram.org/bots/api#answerinlinequery', 'description' => 'you enter: ' . $query, 'input_message_content' => new InputTextMessageContent(['message_text' => ' ' . $query])],
];
$array_article = [];
foreach ($articles as $article) {
$array_article[] = new InlineQueryResultArticle($article);
$results[] = new InlineQueryResultArticle($article);
}
$data['results'] = '[' . implode(',', $array_article) . ']';
}
$data['results'] = '[' . implode(',', $results) . ']';
return Request::answerInlineQuery($data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment