@@ -219,12 +219,12 @@ public static function getInput()
219
219
}
220
220
221
221
// Make sure we have a string to work with.
222
- if (is_string ($ input )) {
223
- self ::$ input = $ input ;
224
- } else {
222
+ if (!is_string ($ input )) {
225
223
throw new TelegramException ('Input must be a string! ' );
226
224
}
227
225
226
+ self ::$ input = $ input ;
227
+
228
228
TelegramLog::update (self ::$ input );
229
229
230
230
return self ::$ input ;
@@ -281,7 +281,7 @@ public static function generateGeneralFakeServerResponse(array $data = [])
281
281
private static function setUpRequestParams (array $ data )
282
282
{
283
283
$ has_resource = false ;
284
- $ multipart = [];
284
+ $ multipart = [];
285
285
286
286
// Convert any nested arrays into JSON strings.
287
287
array_walk ($ data , function (&$ item ) {
@@ -291,7 +291,7 @@ private static function setUpRequestParams(array $data)
291
291
//Reformat data array in multipart way if it contains a resource
292
292
foreach ($ data as $ key => $ item ) {
293
293
$ has_resource |= (is_resource ($ item ) || $ item instanceof \GuzzleHttp \Psr7 \Stream);
294
- $ multipart [] = ['name ' => $ key , 'contents ' => $ item ];
294
+ $ multipart [] = ['name ' => $ key , 'contents ' => $ item ];
295
295
}
296
296
if ($ has_resource ) {
297
297
return ['multipart ' => $ multipart ];
@@ -316,16 +316,16 @@ public static function execute($action, array $data = [])
316
316
$ data ['reply_markup ' ] = json_encode ($ data ['reply_markup ' ]);
317
317
}
318
318
319
- $ result = null ;
320
- $ request_params = self ::setUpRequestParams ($ data );
319
+ $ result = null ;
320
+ $ request_params = self ::setUpRequestParams ($ data );
321
321
$ request_params ['debug ' ] = TelegramLog::getDebugLogTempStream ();
322
322
323
323
try {
324
324
$ response = self ::$ client ->post (
325
325
'/bot ' . self ::$ telegram ->getApiKey () . '/ ' . $ action ,
326
326
$ request_params
327
327
);
328
- $ result = (string ) $ response ->getBody ();
328
+ $ result = (string ) $ response ->getBody ();
329
329
330
330
//Logging getUpdates Update
331
331
if ($ action === 'getUpdates ' ) {
@@ -404,6 +404,7 @@ public static function encodeFile($file)
404
404
* Send command
405
405
*
406
406
* @todo Fake response doesn't need json encoding?
407
+ * @todo Write debug entry on failure
407
408
*
408
409
* @param string $action
409
410
* @param array $data
@@ -598,7 +599,7 @@ public static function setLimiter($value = true, array $options = [])
598
599
}
599
600
600
601
self ::$ limiter_interval = $ options ['interval ' ];
601
- self ::$ limiter_enabled = $ value ;
602
+ self ::$ limiter_enabled = $ value ;
602
603
}
603
604
}
604
605
@@ -636,7 +637,7 @@ private static function limitTelegramRequests($action, array $data = [])
636
637
'setChatDescription ' ,
637
638
];
638
639
639
- $ chat_id = isset ($ data ['chat_id ' ]) ? $ data ['chat_id ' ] : null ;
640
+ $ chat_id = isset ($ data ['chat_id ' ]) ? $ data ['chat_id ' ] : null ;
640
641
$ inline_message_id = isset ($ data ['inline_message_id ' ]) ? $ data ['inline_message_id ' ] : null ;
641
642
642
643
if (($ chat_id || $ inline_message_id ) && in_array ($ action , $ limited_methods )) {
@@ -649,7 +650,7 @@ private static function limitTelegramRequests($action, array $data = [])
649
650
650
651
$ requests = DB ::getTelegramRequestCount ($ chat_id , $ inline_message_id );
651
652
652
- $ chat_per_second = ($ requests ['LIMIT_PER_SEC ' ] == 0 ); // No more than one message per second inside a particular chat
653
+ $ chat_per_second = ($ requests ['LIMIT_PER_SEC ' ] == 0 ); // No more than one message per second inside a particular chat
653
654
$ global_per_second = ($ requests ['LIMIT_PER_SEC_ALL ' ] < 30 ); // No more than 30 messages per second to different chats
654
655
$ groups_per_minute = (((is_numeric ($ chat_id ) && $ chat_id > 0 ) || !is_null ($ inline_message_id )) || ((!is_numeric ($ chat_id ) || $ chat_id < 0 ) && $ requests ['LIMIT_PER_MINUTE ' ] < 20 )); // No more than 20 messages per minute in groups and channels
655
656
0 commit comments