Skip to content

Commit f548fa0

Browse files
committed
Merge pull request #105 from MBoretto/empty_response
2 parents d49436d + f11e45e commit f548fa0

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/Commands/SystemCommand.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace Longman\TelegramBot\Commands;
1212

13-
use Longman\TelegramBot\Entities\ServerResponse;
13+
use Longman\TelegramBot\Request;
1414

1515
/**
1616
* Abstract System Command Class
@@ -27,7 +27,7 @@ abstract class SystemCommand extends Command
2727
*/
2828
public function execute()
2929
{
30-
//System command, return successful ServerResponse
31-
return new ServerResponse(['ok' => true, 'result' => true], null);
30+
//System command, return empty ServerResponse
31+
return Request::emptyResponse();
3232
}
3333
}

src/Request.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public static function getInput()
109109
* @todo Take log verbosity into account
110110
*
111111
* @param string $string
112+
*
112113
* @return mixed
113114
*/
114115
private static function log($string)
@@ -129,6 +130,7 @@ private static function log($string)
129130
* Generate general fake server response
130131
*
131132
* @param array $data Data to add to fake response
133+
*
132134
* @return array Fake response data
133135
*/
134136
public static function generateGeneralFakeServerResponse(array $data = null)
@@ -167,6 +169,7 @@ public static function generateGeneralFakeServerResponse(array $data = null)
167169
*
168170
* @param string $action Action to execute
169171
* @param array|null $data Data to attach to the execution
172+
*
170173
* @return mixed Result of the cURL call
171174
*/
172175
public static function executeCurl($action, array $data = null)
@@ -227,6 +230,7 @@ public static function executeCurl($action, array $data = null)
227230
* Download file
228231
*
229232
* @param Entities\File $file
233+
*
230234
* @return boolean
231235
*/
232236
public static function downloadFile(File $file)
@@ -281,6 +285,7 @@ public static function downloadFile(File $file)
281285
* Encode file
282286
*
283287
* @param string $file
288+
*
284289
* @return CURLFile
285290
*/
286291
protected static function encodeFile($file)
@@ -296,6 +301,7 @@ protected static function encodeFile($file)
296301
*
297302
* @param string $action
298303
* @param array|null $data
304+
*
299305
* @return Entities\ServerResponse
300306
*/
301307
public static function send($action, array $data = null)
@@ -331,6 +337,7 @@ public static function getMe()
331337
* @todo Could do with some cleaner recursion
332338
*
333339
* @param array $data
340+
*
334341
* @return mixed
335342
*/
336343
public static function sendMessage(array $data)
@@ -353,6 +360,7 @@ public static function sendMessage(array $data)
353360
* Forward message
354361
*
355362
* @param array $data
363+
*
356364
* @return mixed
357365
*/
358366
public static function forwardMessage(array $data)
@@ -369,6 +377,7 @@ public static function forwardMessage(array $data)
369377
*
370378
* @param array $data
371379
* @param string $file
380+
*
372381
* @return mixed
373382
*/
374383
public static function sendPhoto(array $data, $file = null)
@@ -389,6 +398,7 @@ public static function sendPhoto(array $data, $file = null)
389398
*
390399
* @param array $data
391400
* @param string $file
401+
*
392402
* @return mixed
393403
*/
394404
public static function sendAudio(array $data, $file = null)
@@ -409,6 +419,7 @@ public static function sendAudio(array $data, $file = null)
409419
*
410420
* @param array $data
411421
* @param string $file
422+
*
412423
* @return mixed
413424
*/
414425
public static function sendDocument(array $data, $file = null)
@@ -429,6 +440,7 @@ public static function sendDocument(array $data, $file = null)
429440
*
430441
* @param array $data
431442
* @param string $file
443+
*
432444
* @return mixed
433445
*/
434446
public static function sendSticker(array $data, $file = null)
@@ -449,6 +461,7 @@ public static function sendSticker(array $data, $file = null)
449461
*
450462
* @param array $data
451463
* @param string $file
464+
*
452465
* @return mixed
453466
*/
454467
public static function sendVideo(array $data, $file = null)
@@ -469,6 +482,7 @@ public static function sendVideo(array $data, $file = null)
469482
*
470483
* @param array $data
471484
* @param string $file
485+
*
472486
* @return mixed
473487
*/
474488
public static function sendVoice(array $data, $file = null)
@@ -488,6 +502,7 @@ public static function sendVoice(array $data, $file = null)
488502
* Send location
489503
*
490504
* @param array $data
505+
*
491506
* @return mixed
492507
*/
493508
public static function sendLocation(array $data)
@@ -503,6 +518,7 @@ public static function sendLocation(array $data)
503518
* Send chat action
504519
*
505520
* @param array $data
521+
*
506522
* @return mixed
507523
*/
508524
public static function sendChatAction(array $data)
@@ -518,6 +534,7 @@ public static function sendChatAction(array $data)
518534
* Get user profile photos
519535
*
520536
* @param array $data
537+
*
521538
* @return mixed
522539
*/
523540
public static function getUserProfilePhotos(array $data)
@@ -537,6 +554,7 @@ public static function getUserProfilePhotos(array $data)
537554
* Get updates
538555
*
539556
* @param array $data
557+
*
540558
* @return mixed
541559
*/
542560
public static function getUpdates(array $data)
@@ -549,6 +567,7 @@ public static function getUpdates(array $data)
549567
*
550568
* @param string $url
551569
* @param string $file
570+
*
552571
* @return mixed
553572
*/
554573
public static function setWebhook($url = '', $file = null)
@@ -566,6 +585,7 @@ public static function setWebhook($url = '', $file = null)
566585
* Get file
567586
*
568587
* @param array $data
588+
*
569589
* @return mixed
570590
*/
571591
public static function getFile(array $data)
@@ -581,6 +601,7 @@ public static function getFile(array $data)
581601
* Answer inline query
582602
*
583603
* @param array $data
604+
*
584605
* @return mixed
585606
*/
586607
public static function answerInlineQuery(array $data)
@@ -592,6 +613,19 @@ public static function answerInlineQuery(array $data)
592613
return self::send('answerInlineQuery', $data);
593614
}
594615

616+
/**
617+
* Return an empty Server Response
618+
*
619+
* No request to telegram are sent, this function is used in commands that
620+
* don't need to fire a message after execution
621+
*
622+
* @return Entities\ServerResponse
623+
*/
624+
public static function emptyResponse()
625+
{
626+
return new ServerResponse(['ok' => true, 'result' => true], null);
627+
}
628+
595629
/**
596630
* Send message to all active chats
597631
*
@@ -602,6 +636,7 @@ public static function answerInlineQuery(array $data)
602636
* @param boolean $send_users
603637
* @param string $date_from
604638
* @param string $date_to
639+
*
605640
* @return array
606641
*/
607642
public static function sendToActiveChats(

0 commit comments

Comments
 (0)