Commit dd0b61f4 authored by Marco Boretto's avatar Marco Boretto Committed by GitHub

Merge pull request #241 from noplanman/no_empty_inline_query

Return an empty response when an empty inline query is passed.
parents 5c621504 2e6f8688
......@@ -25,7 +25,7 @@ class InlinequeryCommand extends SystemCommand
*/
protected $name = 'inlinequery';
protected $description = 'Reply to inline query';
protected $version = '1.0.1';
protected $version = '1.0.2';
/**#@-*/
/**
......@@ -37,19 +37,22 @@ class InlinequeryCommand extends SystemCommand
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
$data['inline_query_id'] = $inline_query->getId();
$data = ['inline_query_id' => $inline_query->getId()];
$results = [];
$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 ])],
];
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])],
];
$array_article = [];
foreach ($articles as $article) {
$array_article[] = new InlineQueryResultArticle($article);
foreach ($articles as $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