Introduce console kernel class and handle cli update requests

parent a2f6ee78
...@@ -45,7 +45,7 @@ class ChatsCommand extends AdminCommand ...@@ -45,7 +45,7 @@ class ChatsCommand extends AdminCommand
/** /**
* Command execute method * Command execute method
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function execute()
......
...@@ -326,7 +326,7 @@ class CleanupCommand extends AdminCommand ...@@ -326,7 +326,7 @@ class CleanupCommand extends AdminCommand
/** /**
* Execution if MySQL is required but not available * Execution if MySQL is required but not available
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function executeNoDb() public function executeNoDb()
{ {
...@@ -345,7 +345,7 @@ class CleanupCommand extends AdminCommand ...@@ -345,7 +345,7 @@ class CleanupCommand extends AdminCommand
/** /**
* Command execute method * Command execute method
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function execute()
......
...@@ -12,7 +12,7 @@ namespace Longman\TelegramBot\Commands\AdminCommands; ...@@ -12,7 +12,7 @@ namespace Longman\TelegramBot\Commands\AdminCommands;
use Longman\TelegramBot\Commands\AdminCommand; use Longman\TelegramBot\Commands\AdminCommand;
use Longman\TelegramBot\Entities\Message; use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Http\ServerResponse; use Longman\TelegramBot\Http\Response;
use Longman\TelegramBot\Http\Client; use Longman\TelegramBot\Http\Client;
/** /**
...@@ -48,7 +48,7 @@ class SendtoallCommand extends AdminCommand ...@@ -48,7 +48,7 @@ class SendtoallCommand extends AdminCommand
/** /**
* Execute command * Execute command
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function execute()
...@@ -59,7 +59,7 @@ class SendtoallCommand extends AdminCommand ...@@ -59,7 +59,7 @@ class SendtoallCommand extends AdminCommand
return $this->replyToChat('Usage: ' . $this->getUsage()); return $this->replyToChat('Usage: ' . $this->getUsage());
} }
/** @var ServerResponse[] $results */ /** @var Response[] $results */
$results = Client::sendToActiveChats( $results = Client::sendToActiveChats(
'sendMessage', //callback function to execute (see Request.php methods) 'sendMessage', //callback function to execute (see Request.php methods)
['text' => $text], //Param to evaluate the request ['text' => $text], //Param to evaluate the request
......
...@@ -54,7 +54,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -54,7 +54,7 @@ class SendtochannelCommand extends AdminCommand
/** /**
* Command execute method * Command execute method
* *
* @return \Longman\TelegramBot\Http\ServerResponse|mixed * @return \Longman\TelegramBot\Http\Response|mixed
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function execute()
...@@ -275,7 +275,7 @@ class SendtochannelCommand extends AdminCommand ...@@ -275,7 +275,7 @@ class SendtochannelCommand extends AdminCommand
* @param \Longman\TelegramBot\Entities\Message $message * @param \Longman\TelegramBot\Entities\Message $message
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
protected function sendBack(Message $message, array $data) protected function sendBack(Message $message, array $data)
......
...@@ -52,7 +52,7 @@ class WhoisCommand extends AdminCommand ...@@ -52,7 +52,7 @@ class WhoisCommand extends AdminCommand
/** /**
* Command execute method * Command execute method
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function execute()
......
...@@ -143,7 +143,7 @@ abstract class Command ...@@ -143,7 +143,7 @@ abstract class Command
/** /**
* Pre-execute command * Pre-execute command
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function preExecute() public function preExecute()
...@@ -176,7 +176,7 @@ abstract class Command ...@@ -176,7 +176,7 @@ abstract class Command
/** /**
* Execute command * Execute command
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
abstract public function execute(); abstract public function execute();
...@@ -184,7 +184,7 @@ abstract class Command ...@@ -184,7 +184,7 @@ abstract class Command
/** /**
* Execution if MySQL is required but not available * Execution if MySQL is required but not available
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function executeNoDb() public function executeNoDb()
...@@ -393,7 +393,7 @@ abstract class Command ...@@ -393,7 +393,7 @@ abstract class Command
* @param string $text * @param string $text
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function replyToChat($text, array $data = []) public function replyToChat($text, array $data = [])
{ {
...@@ -413,7 +413,7 @@ abstract class Command ...@@ -413,7 +413,7 @@ abstract class Command
* @param string $text * @param string $text
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function replyToUser($text, array $data = []) public function replyToUser($text, array $data = [])
{ {
......
...@@ -20,7 +20,7 @@ abstract class SystemCommand extends Command ...@@ -20,7 +20,7 @@ abstract class SystemCommand extends Command
* Although system commands should just work and return a successful ServerResponse, * Although system commands should just work and return a successful ServerResponse,
* each system command can override this method to add custom functionality. * each system command can override this method to add custom functionality.
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function execute() public function execute()
{ {
......
...@@ -42,7 +42,7 @@ class GenericmessageCommand extends SystemCommand ...@@ -42,7 +42,7 @@ class GenericmessageCommand extends SystemCommand
/** /**
* Execution if MySQL is required but not available * Execution if MySQL is required but not available
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function executeNoDb() public function executeNoDb()
{ {
...@@ -53,7 +53,7 @@ class GenericmessageCommand extends SystemCommand ...@@ -53,7 +53,7 @@ class GenericmessageCommand extends SystemCommand
/** /**
* Execute command * Execute command
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function execute() public function 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\Console;
use Longman\TelegramBot\DB;
use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Http\Client;
use Longman\TelegramBot\Http\Request;
use Longman\TelegramBot\Http\Response;
use Longman\TelegramBot\Telegram;
class Kernel
{
/**
* The application implementation.
*
* @var \Longman\TelegramBot\Telegram
*/
protected $app;
/**
* Create a new HTTP kernel instance.
*
* @param \Longman\TelegramBot\Telegram $app
*
* @return void
*/
public function __construct(Telegram $app)
{
$this->app = $app;
}
/**
* Handle an incoming HTTP request.
*
* @param \Longman\TelegramBot\Http\Request $request
*
* @param null $limit
* @param null $timeout
* @return \Longman\TelegramBot\Http\Response
*
*/
public function handle(Request $request, $limit = null, $timeout = null)
{
if (! DB::isDbConnected() && ! $this->app->getupdates_without_database) {
return new Response(
[
'ok' => false,
'description' => 'getUpdates needs MySQL connection! (This can be overridden - see documentation)',
],
$this->bot_username
);
}
$offset = 0;
//Take custom input into account.
if ($custom_input = $this->app->getCustomInput()) {
$response = new Response(json_decode($custom_input, true), $this->app->getBotUsername());
} else {
if (DB::isDbConnected()) {
//Get last update id from the database
$last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
$this->app->last_update_id = isset($last_update['id']) ? $last_update['id'] : null;
}
if ($this->app->last_update_id !== null) {
$offset = $this->app->last_update_id + 1; //As explained in the telegram bot API documentation
}
$response = Client::getUpdates(
[
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]
);
}
if ($response->isOk()) {
$results = $response->getResult();
//Process all updates
/** @var Update $result */
foreach ($results as $result) {
$this->app->processUpdate($result);
}
if (! DB::isDbConnected() && ! $custom_input && $this->app->last_update_id !== null && $offset === 0) {
//Mark update(s) as read after handling
Client::getUpdates(
[
'offset' => $this->app->last_update_id + 1,
'limit' => 1,
'timeout' => $timeout,
]
);
}
}
return $response;
}
}
...@@ -48,7 +48,7 @@ class PreCheckoutQuery extends Entity ...@@ -48,7 +48,7 @@ class PreCheckoutQuery extends Entity
* @param bool $ok * @param bool $ok
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function answer($ok, array $data = []) public function answer($ok, array $data = [])
{ {
......
...@@ -45,7 +45,7 @@ class ShippingQuery extends Entity ...@@ -45,7 +45,7 @@ class ShippingQuery extends Entity
* @param bool $ok * @param bool $ok
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function answer($ok, array $data = []) public function answer($ok, array $data = [])
{ {
......
...@@ -21,123 +21,123 @@ use Longman\TelegramBot\TelegramLog; ...@@ -21,123 +21,123 @@ use Longman\TelegramBot\TelegramLog;
/** /**
* Class Client * Class Client
* *
* @method static ServerResponse getUpdates(array $data) Use this method to receive incoming updates using long polling (wiki). An Array of Update * @method static Response getUpdates(array $data) Use this method to receive incoming updates using long polling (wiki). An Array of Update
* objects is returned. * objects is returned.
* @method static ServerResponse setWebhook(array $data) Use this method to specify a url and receive incoming updates via an outgoing webhook. * @method static Response setWebhook(array $data) Use this method to specify a url and receive incoming updates via an outgoing webhook.
* Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an * Whenever there is an update for the bot, we will send an HTTPS POST request to the specified url, containing a JSON-serialized Update. In case of an
* unsuccessful request, we will give up after a reasonable amount of attempts. Returns true. * unsuccessful request, we will give up after a reasonable amount of attempts. Returns true.
* @method static ServerResponse deleteWebhook() Use this method to remove webhook integration if you decide to switch back to getUpdates. * @method static Response deleteWebhook() Use this method to remove webhook integration if you decide to switch back to getUpdates.
* Returns True on success. Requires no parameters. * Returns True on success. Requires no parameters.
* @method static ServerResponse getWebhookInfo() Use this method to get current webhook status. Requires no parameters. On success, * @method static Response getWebhookInfo() Use this method to get current webhook status. Requires no parameters. On success,
* returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty. * returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.
* @method static ServerResponse getMe() A simple method for testing your bot's auth token. Requires no parameters. Returns basic * @method static Response getMe() A simple method for testing your bot's auth token. Requires no parameters. Returns basic
* information about the bot in form of a User object. * information about the bot in form of a User object.
* @method static ServerResponse forwardMessage(array $data) Use this method to forward messages of any kind. On success, the sent Message is * @method static Response forwardMessage(array $data) Use this method to forward messages of any kind. On success, the sent Message is
* returned. * returned.
* @method static ServerResponse sendPhoto(array $data) Use this method to send photos. On success, the sent Message is returned. * @method static Response sendPhoto(array $data) Use this method to send photos. On success, the sent Message is returned.
* @method static ServerResponse sendAudio(array $data) Use this method to send audio files, if you want Telegram clients to display them in the * @method static Response sendAudio(array $data) Use this method to send audio files, if you want Telegram clients to display them in the
* music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in * music player. Your audio must be in the .mp3 format. On success, the sent Message is returned. Bots can currently send audio files of up to 50 MB in
* size, this limit may be changed in the future. * size, this limit may be changed in the future.
* @method static ServerResponse sendDocument(array $data) Use this method to send general files. On success, the sent Message is returned. Bots can * @method static Response sendDocument(array $data) Use this method to send general files. On success, the sent Message is returned. Bots can
* currently send files of any type of up to 50 MB in size, this limit may be changed in the future. * currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
* @method static ServerResponse sendSticker(array $data) Use this method to send .webp stickers. On success, the sent Message is returned. * @method static Response sendSticker(array $data) Use this method to send .webp stickers. On success, the sent Message is returned.
* @method static ServerResponse sendVideo(array $data) Use this method to send video files, Telegram clients support mp4 videos (other formats * @method static Response sendVideo(array $data) Use this method to send video files, Telegram clients support mp4 videos (other formats
* may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be * may be sent as Document). On success, the sent Message is returned. Bots can currently send video files of up to 50 MB in size, this limit may be
* changed in the future. * changed in the future.
* @method static ServerResponse sendVoice(array $data) Use this method to send audio files, if you want Telegram clients to display the file as * @method static Response sendVoice(array $data) Use this method to send audio files, if you want Telegram clients to display the file as
* a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On * a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On
* success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future. * success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
* @method static ServerResponse sendVideoNote(array $data) Use this method to send video messages. On success, the sent Message is returned. * @method static Response sendVideoNote(array $data) Use this method to send video messages. On success, the sent Message is returned.
* @method static ServerResponse sendMediaGroup(array $data) Use this method to send a group of photos or videos as an album. On success, an array of * @method static Response sendMediaGroup(array $data) Use this method to send a group of photos or videos as an album. On success, an array of
* the sent Messages is returned. * the sent Messages is returned.
* @method static ServerResponse sendLocation(array $data) Use this method to send point on the map. On success, the sent Message is returned. * @method static Response sendLocation(array $data) Use this method to send point on the map. On success, the sent Message is returned.
* @method static ServerResponse editMessageLiveLocation(array $data) Use this method to edit live location messages sent by the bot or via the bot (for inline * @method static Response editMessageLiveLocation(array $data) Use this method to edit live location messages sent by the bot or via the bot (for inline
* bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the * bots). A location can be edited until its live_period expires or editing is explicitly disabled by a call to stopMessageLiveLocation. On success, if the
* edited message was sent by the bot, the edited Message is returned, otherwise True is returned. * edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse stopMessageLiveLocation(array $data) Use this method to stop updating a live location message sent by the bot or via the bot * @method static Response stopMessageLiveLocation(array $data) Use this method to stop updating a live location message sent by the bot or via the bot
* (for inline bots) before live_period expires. On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned. * (for inline bots) before live_period expires. On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
* @method static ServerResponse sendVenue(array $data) Use this method to send information about a venue. On success, the sent Message is * @method static Response sendVenue(array $data) Use this method to send information about a venue. On success, the sent Message is
* returned. * returned.
* @method static ServerResponse sendContact(array $data) Use this method to send phone contacts. On success, the sent Message is returned. * @method static Response sendContact(array $data) Use this method to send phone contacts. On success, the sent Message is returned.
* @method static ServerResponse sendChatAction(array $data) Use this method when you need to tell the user that something is happening on the bot's * @method static Response sendChatAction(array $data) Use this method when you need to tell the user that something is happening on the bot's
* side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success. * side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status). Returns True on success.
* @method static ServerResponse getUserProfilePhotos(array $data) Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos * @method static Response getUserProfilePhotos(array $data) Use this method to get a list of profile pictures for a user. Returns a UserProfilePhotos
* object. * object.
* @method static ServerResponse getFile(array $data) Use this method to get basic info about a file and prepare it for downloading. For the * @method static Response getFile(array $data) Use this method to get basic info about a file and prepare it for downloading. For the
* moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link * moment, bots can download files of up to 20MB in size. On success, a File object is returned. The file can then be downloaded via the link
* https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at * https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is taken from the response. It is guaranteed that the link will be valid for at
* least 1 hour. When the link expires, a new one can be requested by calling getFile again. * least 1 hour. When the link expires, a new one can be requested by calling getFile again.
* @method static ServerResponse kickChatMember(array $data) Use this method to kick a user from a group, a supergroup or a channel. In the case of * @method static Response kickChatMember(array $data) Use this method to kick a user from a group, a supergroup or a channel. In the case of
* supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be * supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be
* an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. * an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse unbanChatMember(array $data) Use this method to unban a previously kicked user in a supergroup or channel. The user * @method static Response unbanChatMember(array $data) Use this method to unban a previously kicked user in a supergroup or channel. The user
* will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work. * will not return to the group or channel automatically, but will be able to join via link, etc. The bot must be an administrator for this to work.
* Returns True on success. * Returns True on success.
* @method static ServerResponse restrictChatMember(array $data) Use this method to restrict a user in a supergroup. The bot must be an administrator in * @method static Response restrictChatMember(array $data) Use this method to restrict a user in a supergroup. The bot must be an administrator in
* the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. * the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
* Returns True on success. * Returns True on success.
* @method static ServerResponse promoteChatMember(array $data) Use this method to promote or demote a user in a supergroup or a channel. The bot must be * @method static Response promoteChatMember(array $data) Use this method to promote or demote a user in a supergroup or a channel. The bot must be
* an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user. * an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
* Returns True on success. * Returns True on success.
* @method static ServerResponse exportChatInviteLink(array $data) Use this method to export an invite link to a supergroup or a channel. The bot must be an * @method static Response exportChatInviteLink(array $data) Use this method to export an invite link to a supergroup or a channel. The bot must be an
* administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success. * administrator in the chat for this to work and must have the appropriate admin rights. Returns exported invite link as String on success.
* @method static ServerResponse setChatPhoto(array $data) Use this method to set a new profile photo for the chat. Photos can't be changed for * @method static Response setChatPhoto(array $data) Use this method to set a new profile photo for the chat. Photos can't be changed for
* private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. * private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse deleteChatPhoto(array $data) Use this method to delete a chat photo. Photos can't be changed for private chats. The * @method static Response deleteChatPhoto(array $data) Use this method to delete a chat photo. Photos can't be changed for private chats. The
* bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. * bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse setChatTitle(array $data) Use this method to change the title of a chat. Titles can't be changed for private chats. * @method static Response setChatTitle(array $data) Use this method to change the title of a chat. Titles can't be changed for private chats.
* The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse setChatDescription(array $data) Use this method to change the description of a supergroup or a channel. The bot must be * @method static Response setChatDescription(array $data) Use this method to change the description of a supergroup or a channel. The bot must be
* an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success. * an administrator in the chat for this to work and must have the appropriate admin rights. Returns True on success.
* @method static ServerResponse pinChatMessage(array $data) Use this method to pin a message in a supergroup or a channel. The bot must be an * @method static Response pinChatMessage(array $data) Use this method to pin a message in a supergroup or a channel. The bot must be an
* administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the * administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the
* channel. Returns True on success. * channel. Returns True on success.
* @method static ServerResponse unpinChatMessage(array $data) Use this method to unpin a message in a supergroup or a channel. The bot must be an * @method static Response unpinChatMessage(array $data) Use this method to unpin a message in a supergroup or a channel. The bot must be an
* administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the * administrator in the chat for this to work and must have the ‘can_pin_messages’ admin right in the supergroup or ‘can_edit_messages’ admin right in the
* channel. Returns True on success. * channel. Returns True on success.
* @method static ServerResponse leaveChat(array $data) Use this method for your bot to leave a group, supergroup or channel. Returns True on * @method static Response leaveChat(array $data) Use this method for your bot to leave a group, supergroup or channel. Returns True on
* success. * success.
* @method static ServerResponse getChat(array $data) Use this method to get up to date information about the chat (current name of the user * @method static Response getChat(array $data) Use this method to get up to date information about the chat (current name of the user
* for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success. * for one-on-one conversations, current username of a user, group or channel, etc.). Returns a Chat object on success.
* @method static ServerResponse getChatAdministrators(array $data) Use this method to get a list of administrators in a chat. On success, returns an Array * @method static Response getChatAdministrators(array $data) Use this method to get a list of administrators in a chat. On success, returns an Array
* of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no * of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no
* administrators were appointed, only the creator will be returned. * administrators were appointed, only the creator will be returned.
* @method static ServerResponse getChatMembersCount(array $data) Use this method to get the number of members in a chat. Returns Int on success. * @method static Response getChatMembersCount(array $data) Use this method to get the number of members in a chat. Returns Int on success.
* @method static ServerResponse getChatMember(array $data) Use this method to get information about a member of a chat. Returns a ChatMember object * @method static Response getChatMember(array $data) Use this method to get information about a member of a chat. Returns a ChatMember object
* on success. * on success.
* @method static ServerResponse setChatStickerSet(array $data) Use this method to set a new group sticker set for a supergroup. The bot must be an * @method static Response setChatStickerSet(array $data) Use this method to set a new group sticker set for a supergroup. The bot must be an
* administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat * administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat
* requests to check if the bot can use this method. Returns True on success. * requests to check if the bot can use this method. Returns True on success.
* @method static ServerResponse deleteChatStickerSet(array $data) Use this method to delete a group sticker set from a supergroup. The bot must be an * @method static Response deleteChatStickerSet(array $data) Use this method to delete a group sticker set from a supergroup. The bot must be an
* administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat * administrator in the chat for this to work and must have the appropriate admin rights. Use the field can_set_sticker_set optionally returned in getChat
* requests to check if the bot can use this method. Returns True on success. * requests to check if the bot can use this method. Returns True on success.
* @method static ServerResponse answerCallbackQuery(array $data) Use this method to send answers to callback queries sent from inline keyboards. The * @method static Response answerCallbackQuery(array $data) Use this method to send answers to callback queries sent from inline keyboards. The
* answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. * answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.
* @method static ServerResponse answerInlineQuery(array $data) Use this method to send answers to an inline query. On success, True is returned. * @method static Response answerInlineQuery(array $data) Use this method to send answers to an inline query. On success, True is returned.
* @method static ServerResponse editMessageText(array $data) Use this method to edit text and game messages sent by the bot or via the bot (for inline * @method static Response editMessageText(array $data) Use this method to edit text and game messages sent by the bot or via the bot (for inline
* bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. * bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse editMessageCaption(array $data) Use this method to edit captions of messages sent by the bot or via the bot (for inline * @method static Response editMessageCaption(array $data) Use this method to edit captions of messages sent by the bot or via the bot (for inline
* bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. * bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse editMessageReplyMarkup(array $data) Use this method to edit only the reply markup of messages sent by the bot or via the bot * @method static Response editMessageReplyMarkup(array $data) Use this method to edit only the reply markup of messages sent by the bot or via the bot
* (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned. * (for inline bots). On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @method static ServerResponse deleteMessage(array $data) Use this method to delete a message, including service messages, with certain * @method static Response deleteMessage(array $data) Use this method to delete a message, including service messages, with certain
* limitations. Returns True on success. * limitations. Returns True on success.
* @method static ServerResponse getStickerSet(array $data) Use this method to get a sticker set. On success, a StickerSet object is returned. * @method static Response getStickerSet(array $data) Use this method to get a sticker set. On success, a StickerSet object is returned.
* @method static ServerResponse uploadStickerFile(array $data) Use this method to upload a .png file with a sticker for later use in createNewStickerSet * @method static Response uploadStickerFile(array $data) Use this method to upload a .png file with a sticker for later use in createNewStickerSet
* and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success. * and addStickerToSet methods (can be used multiple times). Returns the uploaded File on success.
* @method static ServerResponse createNewStickerSet(array $data) Use this method to create new sticker set owned by a user. The bot will be able to edit * @method static Response createNewStickerSet(array $data) Use this method to create new sticker set owned by a user. The bot will be able to edit
* the created sticker set. Returns True on success. * the created sticker set. Returns True on success.
* @method static ServerResponse addStickerToSet(array $data) Use this method to add a new sticker to a set created by the bot. Returns True on * @method static Response addStickerToSet(array $data) Use this method to add a new sticker to a set created by the bot. Returns True on
* success. * success.
* @method static ServerResponse setStickerPositionInSet(array $data) Use this method to move a sticker in a set created by the bot to a specific position. * @method static Response setStickerPositionInSet(array $data) Use this method to move a sticker in a set created by the bot to a specific position.
* Returns True on success. * Returns True on success.
* @method static ServerResponse deleteStickerFromSet(array $data) Use this method to delete a sticker from a set created by the bot. Returns True on * @method static Response deleteStickerFromSet(array $data) Use this method to delete a sticker from a set created by the bot. Returns True on
* success. * success.
* @method static ServerResponse sendInvoice(array $data) Use this method to send invoices. On success, the sent Message is returned. * @method static Response sendInvoice(array $data) Use this method to send invoices. On success, the sent Message is returned.
* @method static ServerResponse answerShippingQuery(array $data) If you sent an invoice requesting a shipping address and the parameter is_flexible was * @method static Response answerShippingQuery(array $data) If you sent an invoice requesting a shipping address and the parameter is_flexible was
* specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is * specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is
* returned. * returned.
* @method static ServerResponse answerPreCheckoutQuery(array $data) Once the user has confirmed their payment and shipping details, the Bot API sends the * @method static Response answerPreCheckoutQuery(array $data) Once the user has confirmed their payment and shipping details, the Bot API sends the
* final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True * final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True
* is returned. * is returned.
*/ */
...@@ -503,7 +503,7 @@ class Client ...@@ -503,7 +503,7 @@ class Client
* @param string $action * @param string $action
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function send($action, array $data = []) public static function send($action, array $data = [])
...@@ -516,7 +516,7 @@ class Client ...@@ -516,7 +516,7 @@ class Client
if (defined('PHPUNIT_TESTSUITE')) { if (defined('PHPUNIT_TESTSUITE')) {
$fake_response = self::generateGeneralFakeServerResponse($data); $fake_response = self::generateGeneralFakeServerResponse($data);
return new ServerResponse($fake_response, $bot_username); return new Response($fake_response, $bot_username);
} }
self::ensureNonEmptyData($data); self::ensureNonEmptyData($data);
...@@ -529,7 +529,7 @@ class Client ...@@ -529,7 +529,7 @@ class Client
throw new TelegramException('Telegram returned an invalid response! Please review your bot name and API key.'); throw new TelegramException('Telegram returned an invalid response! Please review your bot name and API key.');
} }
return new ServerResponse($response, $bot_username); return new Response($response, $bot_username);
} }
/** /**
...@@ -588,7 +588,7 @@ class Client ...@@ -588,7 +588,7 @@ class Client
* *
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function sendMessage(array $data) public static function sendMessage(array $data)
...@@ -613,7 +613,7 @@ class Client ...@@ -613,7 +613,7 @@ class Client
* @param string $action * @param string $action
* @param array $data * @param array $data
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function __callStatic($action, array $data) public static function __callStatic($action, array $data)
...@@ -631,12 +631,12 @@ class Client ...@@ -631,12 +631,12 @@ class Client
* No request to telegram are sent, this function is used in commands that * No request to telegram are sent, this function is used in commands that
* don't need to fire a message after execution * don't need to fire a message after execution
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public static function emptyResponse() public static function emptyResponse()
{ {
return new ServerResponse(['ok' => true, 'result' => true], null); return new Response(['ok' => true, 'result' => true], null);
} }
/** /**
......
...@@ -37,9 +37,9 @@ class Kernel ...@@ -37,9 +37,9 @@ class Kernel
/** /**
* Handle an incoming HTTP request. * Handle an incoming HTTP request.
* *
* @param \Longman\TelegramBot\Request2 $request * @param \Longman\TelegramBot\Http\Request $request
* *
* @return \Longman\TelegramBot\Response * @return \Longman\TelegramBot\Http\Response
* *
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
......
...@@ -24,7 +24,7 @@ use Longman\TelegramBot\Entities\WebhookInfo; ...@@ -24,7 +24,7 @@ use Longman\TelegramBot\Entities\WebhookInfo;
* *
* @todo method ResponseParameters getParameters() Field which can help to automatically handle the error * @todo method ResponseParameters getParameters() Field which can help to automatically handle the error
*/ */
class ServerResponse class Response
{ {
/** /**
* ServerResponse constructor. * ServerResponse constructor.
......
...@@ -16,12 +16,12 @@ defined('TB_BASE_COMMANDS_PATH') || define('TB_BASE_COMMANDS_PATH', TB_BASE_PATH ...@@ -16,12 +16,12 @@ defined('TB_BASE_COMMANDS_PATH') || define('TB_BASE_COMMANDS_PATH', TB_BASE_PATH
use Exception; use Exception;
use Illuminate\Container\Container; use Illuminate\Container\Container;
use Longman\TelegramBot\Commands\Command; use Longman\TelegramBot\Commands\Command;
use Longman\TelegramBot\Console\Kernel as ConsoleKernel;
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Exception\TelegramException;
use Longman\TelegramBot\Http\Kernel;
use Longman\TelegramBot\Http\Client; use Longman\TelegramBot\Http\Client;
use Longman\TelegramBot\Http\Kernel;
use Longman\TelegramBot\Http\Request; use Longman\TelegramBot\Http\Request;
use Longman\TelegramBot\Http\ServerResponse;
use PDO; use PDO;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
...@@ -130,7 +130,7 @@ class Telegram extends Container ...@@ -130,7 +130,7 @@ class Telegram extends Container
/** /**
* ServerResponse of the last Command execution * ServerResponse of the last Command execution
* *
* @var \Longman\TelegramBot\Http\ServerResponse * @var \Longman\TelegramBot\Http\Response
*/ */
protected $last_command_response; protected $last_command_response;
...@@ -153,7 +153,7 @@ class Telegram extends Container ...@@ -153,7 +153,7 @@ class Telegram extends Container
* *
* @var bool * @var bool
*/ */
protected $getupdates_without_database = false; public $getupdates_without_database = false;
/** /**
* Last update ID * Last update ID
...@@ -161,7 +161,7 @@ class Telegram extends Container ...@@ -161,7 +161,7 @@ class Telegram extends Container
* *
* @var integer * @var integer
*/ */
protected $last_update_id = null; public $last_update_id = null;
/** /**
* Telegram constructor. * Telegram constructor.
...@@ -340,7 +340,7 @@ class Telegram extends Container ...@@ -340,7 +340,7 @@ class Telegram extends Container
/** /**
* Get the ServerResponse of the last Command execution * Get the ServerResponse of the last Command execution
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
*/ */
public function getLastCommandResponse() public function getLastCommandResponse()
{ {
...@@ -353,7 +353,7 @@ class Telegram extends Container ...@@ -353,7 +353,7 @@ class Telegram extends Container
* @param int|null $limit * @param int|null $limit
* @param int|null $timeout * @param int|null $timeout
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function handleGetUpdates($limit = null, $timeout = null) public function handleGetUpdates($limit = null, $timeout = null)
...@@ -362,63 +362,10 @@ class Telegram extends Container ...@@ -362,63 +362,10 @@ class Telegram extends Container
throw new TelegramException('Bot Username is not defined!'); throw new TelegramException('Bot Username is not defined!');
} }
if (! DB::isDbConnected() && ! $this->getupdates_without_database) { /** @var \Longman\TelegramBot\Console\Kernel $kernel */
return new ServerResponse( $kernel = $this->make(ConsoleKernel::class);
[
'ok' => false,
'description' => 'getUpdates needs MySQL connection! (This can be overridden - see documentation)',
],
$this->bot_username
);
}
$offset = 0;
//Take custom input into account.
if ($custom_input = $this->getCustomInput()) {
$response = new ServerResponse(json_decode($custom_input, true), $this->bot_username);
} else {
if (DB::isDbConnected()) {
//Get last update id from the database
$last_update = DB::selectTelegramUpdate(1);
$last_update = reset($last_update);
$this->last_update_id = isset($last_update['id']) ? $last_update['id'] : null;
}
if ($this->last_update_id !== null) {
$offset = $this->last_update_id + 1; //As explained in the telegram bot API documentation
}
$response = Client::getUpdates( $response = $kernel->handle(Request::capture(), $limit, $timeout);
[
'offset' => $offset,
'limit' => $limit,
'timeout' => $timeout,
]
);
}
if ($response->isOk()) {
$results = $response->getResult();
//Process all updates
/** @var Update $result */
foreach ($results as $result) {
$this->processUpdate($result);
}
if (! DB::isDbConnected() && ! $custom_input && $this->last_update_id !== null && $offset === 0) {
//Mark update(s) as read after handling
Client::getUpdates(
[
'offset' => $this->last_update_id + 1,
'limit' => 1,
'timeout' => $timeout,
]
);
}
}
return $response; return $response;
} }
...@@ -461,7 +408,7 @@ class Telegram extends Container ...@@ -461,7 +408,7 @@ class Telegram extends Container
* *
* @param \Longman\TelegramBot\Entities\Update $update * @param \Longman\TelegramBot\Entities\Update $update
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function processUpdate(Update $update) public function processUpdate(Update $update)
...@@ -833,7 +780,7 @@ class Telegram extends Container ...@@ -833,7 +780,7 @@ class Telegram extends Container
*/ */
public function getVersion() public function getVersion()
{ {
return $this->version; return self::VERSION;
} }
/** /**
...@@ -842,7 +789,7 @@ class Telegram extends Container ...@@ -842,7 +789,7 @@ class Telegram extends Container
* @param string $url * @param string $url
* @param array $data Optional parameters. * @param array $data Optional parameters.
* *
* @return \Longman\TelegramBot\Http\ServerResponse * @return \Longman\TelegramBot\Http\Response
* @throws \Longman\TelegramBot\Exception\TelegramException * @throws \Longman\TelegramBot\Exception\TelegramException
*/ */
public function setWebhook($url, array $data = []) public function setWebhook($url, array $data = [])
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
namespace Longman\TelegramBot\Tests\Unit; namespace Longman\TelegramBot\Tests\Unit;
use Longman\TelegramBot\Entities\Message; use Longman\TelegramBot\Entities\Message;
use Longman\TelegramBot\Http\ServerResponse; use Longman\TelegramBot\Http\Response;
use Longman\TelegramBot\Http\Client; use Longman\TelegramBot\Http\Client;
/** /**
...@@ -42,7 +42,7 @@ class ServerResponseTest extends TestCase ...@@ -42,7 +42,7 @@ class ServerResponseTest extends TestCase
public function testSendMessageOk() public function testSendMessageOk()
{ {
$result = $this->sendMessageOk(); $result = $this->sendMessageOk();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
$server_result = $server->getResult(); $server_result = $server->getResult();
self::assertTrue($server->isOk()); self::assertTrue($server->isOk());
...@@ -76,7 +76,7 @@ class ServerResponseTest extends TestCase ...@@ -76,7 +76,7 @@ class ServerResponseTest extends TestCase
public function testSendMessageFail() public function testSendMessageFail()
{ {
$result = $this->sendMessageFail(); $result = $this->sendMessageFail();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertFalse($server->isOk()); self::assertFalse($server->isOk());
self::assertNull($server->getResult()); self::assertNull($server->getResult());
...@@ -92,7 +92,7 @@ class ServerResponseTest extends TestCase ...@@ -92,7 +92,7 @@ class ServerResponseTest extends TestCase
public function testSetWebhookOk() public function testSetWebhookOk()
{ {
$result = $this->setWebhookOk(); $result = $this->setWebhookOk();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertTrue($server->isOk()); self::assertTrue($server->isOk());
self::assertTrue($server->getResult()); self::assertTrue($server->getResult());
...@@ -112,7 +112,7 @@ class ServerResponseTest extends TestCase ...@@ -112,7 +112,7 @@ class ServerResponseTest extends TestCase
public function testSetWebhookFail() public function testSetWebhookFail()
{ {
$result = $this->setWebhookFail(); $result = $this->setWebhookFail();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertFalse($server->isOk()); self::assertFalse($server->isOk());
self::assertNull($server->getResult()); self::assertNull($server->getResult());
...@@ -172,7 +172,7 @@ class ServerResponseTest extends TestCase ...@@ -172,7 +172,7 @@ class ServerResponseTest extends TestCase
public function testGetUpdatesArray() public function testGetUpdatesArray()
{ {
$result = $this->getUpdatesArray(); $result = $this->getUpdatesArray();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertCount(4, $server->getResult()); self::assertCount(4, $server->getResult());
self::assertInstanceOf('\Longman\TelegramBot\Entities\Update', $server->getResult()[0]); self::assertInstanceOf('\Longman\TelegramBot\Entities\Update', $server->getResult()[0]);
...@@ -186,7 +186,7 @@ class ServerResponseTest extends TestCase ...@@ -186,7 +186,7 @@ class ServerResponseTest extends TestCase
public function testGetUpdatesEmpty() public function testGetUpdatesEmpty()
{ {
$result = $this->getUpdatesEmpty(); $result = $this->getUpdatesEmpty();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertEmpty($server->getResult()); self::assertEmpty($server->getResult());
} }
...@@ -221,7 +221,7 @@ class ServerResponseTest extends TestCase ...@@ -221,7 +221,7 @@ class ServerResponseTest extends TestCase
public function testGetUserProfilePhotos() public function testGetUserProfilePhotos()
{ {
$result = $this->getUserProfilePhotos(); $result = $this->getUserProfilePhotos();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
$server_result = $server->getResult(); $server_result = $server->getResult();
$photos = $server_result->getPhotos(); $photos = $server_result->getPhotos();
...@@ -251,7 +251,7 @@ class ServerResponseTest extends TestCase ...@@ -251,7 +251,7 @@ class ServerResponseTest extends TestCase
public function testGetFile() public function testGetFile()
{ {
$result = $this->getFile(); $result = $this->getFile();
$server = new ServerResponse(json_decode($result, true), 'testbot'); $server = new Response(json_decode($result, true), 'testbot');
self::assertInstanceOf('\Longman\TelegramBot\Entities\File', $server->getResult()); self::assertInstanceOf('\Longman\TelegramBot\Entities\File', $server->getResult());
} }
...@@ -261,7 +261,7 @@ class ServerResponseTest extends TestCase ...@@ -261,7 +261,7 @@ class ServerResponseTest extends TestCase
//setWebhook ok //setWebhook ok
$fake_response = Client::generateGeneralFakeServerResponse(); $fake_response = Client::generateGeneralFakeServerResponse();
$server = new ServerResponse($fake_response, 'testbot'); $server = new Response($fake_response, 'testbot');
self::assertTrue($server->isOk()); self::assertTrue($server->isOk());
self::assertTrue($server->getResult()); self::assertTrue($server->getResult());
...@@ -271,7 +271,7 @@ class ServerResponseTest extends TestCase ...@@ -271,7 +271,7 @@ class ServerResponseTest extends TestCase
//sendMessage ok //sendMessage ok
$fake_response = Client::generateGeneralFakeServerResponse(['chat_id' => 123456789, 'text' => 'hello']); $fake_response = Client::generateGeneralFakeServerResponse(['chat_id' => 123456789, 'text' => 'hello']);
$server = new ServerResponse($fake_response, 'testbot'); $server = new Response($fake_response, 'testbot');
/** @var Message $server_result */ /** @var Message $server_result */
$server_result = $server->getResult(); $server_result = $server->getResult();
......
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