Skip to content

Empty response #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Commands/SystemCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace Longman\TelegramBot\Commands;

use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Request;

/**
* Abstract System Command Class
Expand All @@ -27,7 +27,7 @@ abstract class SystemCommand extends Command
*/
public function execute()
{
//System command, return successful ServerResponse
return new ServerResponse(['ok' => true, 'result' => true], null);
//System command, return empty ServerResponse
return Request::emptyResponse();
}
}
35 changes: 35 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public static function getInput()
* @todo Take log verbosity into account
*
* @param string $string
*
* @return mixed
*/
private static function log($string)
Expand All @@ -129,6 +130,7 @@ private static function log($string)
* Generate general fake server response
*
* @param array $data Data to add to fake response
*
* @return array Fake response data
*/
public static function generateGeneralFakeServerResponse(array $data = null)
Expand Down Expand Up @@ -167,6 +169,7 @@ public static function generateGeneralFakeServerResponse(array $data = null)
*
* @param string $action Action to execute
* @param array|null $data Data to attach to the execution
*
* @return mixed Result of the cURL call
*/
public static function executeCurl($action, array $data = null)
Expand Down Expand Up @@ -227,6 +230,7 @@ public static function executeCurl($action, array $data = null)
* Download file
*
* @param Entities\File $file
*
* @return boolean
*/
public static function downloadFile(File $file)
Expand Down Expand Up @@ -281,6 +285,7 @@ public static function downloadFile(File $file)
* Encode file
*
* @param string $file
*
* @return CURLFile
*/
protected static function encodeFile($file)
Expand All @@ -296,6 +301,7 @@ protected static function encodeFile($file)
*
* @param string $action
* @param array|null $data
*
* @return Entities\ServerResponse
*/
public static function send($action, array $data = null)
Expand Down Expand Up @@ -331,6 +337,7 @@ public static function getMe()
* @todo Could do with some cleaner recursion
*
* @param array $data
*
* @return mixed
*/
public static function sendMessage(array $data)
Expand All @@ -353,6 +360,7 @@ public static function sendMessage(array $data)
* Forward message
*
* @param array $data
*
* @return mixed
*/
public static function forwardMessage(array $data)
Expand All @@ -369,6 +377,7 @@ public static function forwardMessage(array $data)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendPhoto(array $data, $file = null)
Expand All @@ -389,6 +398,7 @@ public static function sendPhoto(array $data, $file = null)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendAudio(array $data, $file = null)
Expand All @@ -409,6 +419,7 @@ public static function sendAudio(array $data, $file = null)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendDocument(array $data, $file = null)
Expand All @@ -429,6 +440,7 @@ public static function sendDocument(array $data, $file = null)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendSticker(array $data, $file = null)
Expand All @@ -449,6 +461,7 @@ public static function sendSticker(array $data, $file = null)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendVideo(array $data, $file = null)
Expand All @@ -469,6 +482,7 @@ public static function sendVideo(array $data, $file = null)
*
* @param array $data
* @param string $file
*
* @return mixed
*/
public static function sendVoice(array $data, $file = null)
Expand All @@ -488,6 +502,7 @@ public static function sendVoice(array $data, $file = null)
* Send location
*
* @param array $data
*
* @return mixed
*/
public static function sendLocation(array $data)
Expand All @@ -503,6 +518,7 @@ public static function sendLocation(array $data)
* Send chat action
*
* @param array $data
*
* @return mixed
*/
public static function sendChatAction(array $data)
Expand All @@ -518,6 +534,7 @@ public static function sendChatAction(array $data)
* Get user profile photos
*
* @param array $data
*
* @return mixed
*/
public static function getUserProfilePhotos(array $data)
Expand All @@ -537,6 +554,7 @@ public static function getUserProfilePhotos(array $data)
* Get updates
*
* @param array $data
*
* @return mixed
*/
public static function getUpdates(array $data)
Expand All @@ -549,6 +567,7 @@ public static function getUpdates(array $data)
*
* @param string $url
* @param string $file
*
* @return mixed
*/
public static function setWebhook($url = '', $file = null)
Expand All @@ -566,6 +585,7 @@ public static function setWebhook($url = '', $file = null)
* Get file
*
* @param array $data
*
* @return mixed
*/
public static function getFile(array $data)
Expand All @@ -581,6 +601,7 @@ public static function getFile(array $data)
* Answer inline query
*
* @param array $data
*
* @return mixed
*/
public static function answerInlineQuery(array $data)
Expand All @@ -592,6 +613,19 @@ public static function answerInlineQuery(array $data)
return self::send('answerInlineQuery', $data);
}

/**
* Return an empty Server Response
*
* No request to telegram are sent, this function is used in commands that
* don't need to fire a message after execution
*
* @return Entities\ServerResponse
*/
public static function emptyResponse()
{
return new ServerResponse(['ok' => true, 'result' => true], null);
}

/**
* Send message to all active chats
*
Expand All @@ -602,6 +636,7 @@ public static function answerInlineQuery(array $data)
* @param boolean $send_users
* @param string $date_from
* @param string $date_to
*
* @return array
*/
public static function sendToActiveChats(
Expand Down