Commit aec70278 authored by Jack'lul's avatar Jack'lul

Move default commands to examples

parent 518e9dd8
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Callback query command
*/
class CallbackqueryCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'callbackquery';
/**
* @var string
*/
protected $description = 'Reply to callback query';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$update = $this->getUpdate();
$callback_query = $update->getCallbackQuery();
$callback_query_id = $callback_query->getId();
$callback_data = $callback_query->getData();
$data = [
'callback_query_id' => $callback_query_id,
'text' => 'Hello World!',
'show_alert' => $callback_data === 'thumb up',
'cache_time' => 5,
];
return Request::answerCallbackQuery($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Channel chat created command
*/
class ChannelchatcreatedCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Channelchatcreated';
/**
* @var string
*/
protected $description = 'Channel chat created';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$channel_chat_created = $message->getChannelChatCreated();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Channel post command
*/
class ChannelpostCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Channelpost';
/**
* @var string
*/
protected $description = 'Handle channel post';
/**
* @var string
*/
protected $version = '1.0.0';
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$channel_post = $this->getUpdate()->getChannelPost();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Chosen inline result command
*/
class ChoseninlineresultCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'choseninlineresult';
/**
* @var string
*/
protected $description = 'Chosen result query';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//Information about chosen result is returned
//$update = $this->getUpdate();
//$inline_query = $update->getChosenInlineResult();
//$query = $inline_query->getQuery();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Delete chat photo command
*/
class DeletechatphotoCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Deletechatphoto';
/**
* @var string
*/
protected $description = 'Delete chat photo';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$delete_chat_photo = $message->getDeleteChatPhoto();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Edited channel post command
*/
class EditedchannelpostCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Editedchannelpost';
/**
* @var string
*/
protected $description = 'Handle edited channel post';
/**
* @var string
*/
protected $version = '1.0.0';
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$edited_channel_post = $this->getUpdate()->getEditedChannelPost();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Edited message command
*/
class EditedmessageCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'editedmessage';
/**
* @var string
*/
protected $description = 'User edited message';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$update = $this->getUpdate();
//$edited_message = $update->getEditedMessage();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Generic command
*/
class GenericCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Generic';
/**
* @var string
*/
protected $description = 'Handles generic commands or is executed by default when a command is not found';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$message = $this->getMessage();
//You can use $command as param
$chat_id = $message->getChat()->getId();
$user_id = $message->getFrom()->getId();
$command = $message->getCommand();
//If the user is and admin and the command is in the format "/whoisXYZ", call the /whois command
if (stripos($command, 'whois') === 0 && $this->telegram->isAdmin($user_id)) {
return $this->telegram->executeCommand('whois');
}
$data = [
'chat_id' => $chat_id,
'text' => 'Command /' . $command . ' not found.. :(',
];
return Request::sendMessage($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Conversation;
use Longman\TelegramBot\Request;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Generic message command
*/
class GenericmessageCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Genericmessage';
/**
* @var string
*/
protected $description = 'Handle generic message';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* @var bool
*/
protected $need_mysql = true;
/**
* Execution if MySQL is required but not available
*
* @return \Longman\TelegramBot\Entities\ServerResponse
*/
public function executeNoDb()
{
//Do nothing
return Request::emptyResponse();
}
/**
* Execute command
*
* @return \Longman\TelegramBot\Entities\ServerResponse
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//If a conversation is busy, execute the conversation command after handling the message
$conversation = new Conversation(
$this->getMessage()->getFrom()->getId(),
$this->getMessage()->getChat()->getId()
);
//Fetch conversation command if it exists and execute it
if ($conversation->exists() && ($command = $conversation->getCommand())) {
return $this->telegram->executeCommand($command);
}
return Request::emptyResponse();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Group chat created command
*/
class GroupchatcreatedCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Groupchatcreated';
/**
* @var string
*/
protected $description = 'Group chat created';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$group_chat_created = $message->getGroupChatCreated();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Entities\InlineQuery\InlineQueryResultArticle;
use Longman\TelegramBot\Entities\InputMessageContent\InputTextMessageContent;
use Longman\TelegramBot\Request;
/**
* Inline query command
*/
class InlinequeryCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'inlinequery';
/**
* @var string
*/
protected $description = 'Reply to inline query';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$update = $this->getUpdate();
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
$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]),
],
];
foreach ($articles as $article) {
$results[] = new InlineQueryResultArticle($article);
}
}
$data['results'] = '[' . implode(',', $results) . ']';
return Request::answerInlineQuery($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Left chat member command
*/
class LeftchatmemberCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Leftchatmember';
/**
* @var string
*/
protected $description = 'Left Chat Member';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$member = $message->getLeftChatMember();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Migrate from chat id command
*/
class MigratefromchatidCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Migratefromchatid';
/**
* @var string
*/
protected $description = 'Migrate from chat id';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$migrate_from_chat_id = $message->getMigrateFromChatId();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Migrate to chat id command
*/
class MigratetochatidCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Migratetochatid';
/**
* @var string
*/
protected $description = 'Migrate to chat id';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$migrate_to_chat_id = $message->getMigrateToChatId();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* New chat member command
*/
class NewchatmemberCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Newchatmember';
/**
* @var string
*/
protected $description = 'New Chat Member';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$member = $message->getNewChatMember();
$text = 'Hi there!';
if (!$message->botAddedInChat()) {
$text = 'Hi ' . $member->tryMention() . '!';
}
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* New chat photo command
*/
class NewchatphotoCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Newchatphoto';
/**
* @var string
*/
protected $description = 'New chat Photo';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$new_chat_photo = $message->getNewChatPhoto();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* New chat title command
*/
class NewchattitleCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Newchattitle';
/**
* @var string
*/
protected $description = 'New chat Title';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$new_chat_title = $message->getNewChatTitle();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Pinned message command
*/
class PinnedmessageCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Pinnedmessage';
/**
* @var string
*/
protected $description = 'Message was pinned';
/**
* @var string
*/
protected $version = '1.0.0';
/**
* Execute command
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$pinned_message = $message->getPinnedMessage();
return parent::execute();
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Start command
*/
class StartCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'start';
/**
* @var string
*/
protected $description = 'Start command';
/**
* @var string
*/
protected $usage = '/start';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
$message = $this->getMessage();
$chat_id = $message->getChat()->getId();
$text = 'Hi there!' . PHP_EOL . 'Type /help to see all commands!';
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
}
}
<?php
/**
* This file is part of the TelegramBot package.
*
* (c) Avtandil Kikabidze aka LONGMAN <akalongman@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\SystemCommand;
/**
* Super group chat created command
*/
class SupergroupchatcreatedCommand extends SystemCommand
{
/**
* @var string
*/
protected $name = 'Supergroupchatcreated';
/**
* @var string
*/
protected $description = 'Super group chat created';
/**
* @var string
*/
protected $version = '1.1.0';
/**
* Command execute method
*
* @return mixed
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public function execute()
{
//$message = $this->getMessage();
//$supergroup_chat_created = $message->getSuperGroupChatCreated();
return parent::execute();
}
}
......@@ -42,7 +42,10 @@ try {
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
......
......@@ -43,7 +43,10 @@ try {
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
......
......@@ -42,7 +42,10 @@ try {
// Enable MySQL with table prefix
//$telegram->enableMySql($mysql_credentials, $BOT_NAME . '_');
// Add an additional commands path
// Uncomment this line to load example commands
//$telegram->addCommandsPath(BASE_PATH . '/../examples/Commands');
// Add commands path containing your commands
//$telegram->addCommandsPath($commands_path);
// Enable admin user(s)
......
......@@ -41,18 +41,11 @@ class CallbackqueryCommand extends SystemCommand
*/
public function execute()
{
$update = $this->getUpdate();
$callback_query = $update->getCallbackQuery();
$callback_query_id = $callback_query->getId();
$callback_data = $callback_query->getData();
//$callback_query = $this->getUpdate()->getCallbackQuery();
//$user_id = $callback_query->getFrom()->getId();
//$query_id = $callback_query->getId();
//$query_data = $callback_query->getData();
$data = [
'callback_query_id' => $callback_query_id,
'text' => 'Hello World!',
'show_alert' => $callback_data === 'thumb up',
'cache_time' => 5,
];
return Request::answerCallbackQuery($data);
return Request::answerCallbackQuery(['callback_query_id' => $this->getUpdate()->getCallbackQuery()->getId()]);
}
}
......@@ -41,23 +41,12 @@ class GenericCommand extends SystemCommand
*/
public function execute()
{
$message = $this->getMessage();
//$message = $this->getMessage();
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();
//$command = $message->getCommand();
//#text = trim($message->getText(true));
//You can use $command as param
$chat_id = $message->getChat()->getId();
$user_id = $message->getFrom()->getId();
$command = $message->getCommand();
//If the user is and admin and the command is in the format "/whoisXYZ", call the /whois command
if (stripos($command, 'whois') === 0 && $this->telegram->isAdmin($user_id)) {
return $this->telegram->executeCommand('whois');
}
$data = [
'chat_id' => $chat_id,
'text' => 'Command /' . $command . ' not found.. :(',
];
return Request::sendMessage($data);
return parent::execute();
}
}
......@@ -63,6 +63,7 @@ class GenericmessageCommand extends SystemCommand
$this->getMessage()->getFrom()->getId(),
$this->getMessage()->getChat()->getId()
);
//Fetch conversation command if it exists and execute it
if ($conversation->exists() && ($command = $conversation->getCommand())) {
return $this->telegram->executeCommand($command);
......
......@@ -43,42 +43,10 @@ class InlinequeryCommand extends SystemCommand
*/
public function execute()
{
$update = $this->getUpdate();
$inline_query = $update->getInlineQuery();
$query = $inline_query->getQuery();
//$inline_query = $this->getUpdate()->getInlineQuery();
//$user_id = $inline_query->getFrom()->getId();
//$query = $inline_query->getQuery();
$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]),
],
];
foreach ($articles as $article) {
$results[] = new InlineQueryResultArticle($article);
}
}
$data['results'] = '[' . implode(',', $results) . ']';
return Request::answerInlineQuery($data);
return Request::answerInlineQuery(['inline_query_id' => $this->getUpdate()->getInlineQuery()->getId()]);
}
}
......@@ -46,16 +46,10 @@ class StartCommand extends SystemCommand
*/
public function execute()
{
$message = $this->getMessage();
//$message = $this->getMessage();
//$chat_id = $message->getChat()->getId();
//$user_id = $message->getFrom()->getId();
$chat_id = $message->getChat()->getId();
$text = 'Hi there!' . PHP_EOL . 'Type /help to see all commands!';
$data = [
'chat_id' => $chat_id,
'text' => $text,
];
return Request::sendMessage($data);
return parent::execute();
}
}
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