This commit is contained in:
Daniil Gentili 2019-12-28 18:44:56 +01:00
parent cb2367ab1b
commit a3ad3b5c2f
5 changed files with 56 additions and 10 deletions

View File

@ -5,6 +5,9 @@ php:
- '7.0'
- '5.6'
allow_failures:
- php: '5.6'
before_install:
- echo "phar.readonly = 0" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
- tests/waitPackagist.php

2
docs

@ -1 +1 @@
Subproject commit 757d12fbdda97d22a20d565be8e0aea64ed34cad
Subproject commit 76640a01adf8bfc39e2cc4e3fd2dd586af47c359

View File

@ -556,8 +556,16 @@ trait BotAPI
break;
}
}
private function parseMode($arguments)
/**
* Convert markdown and HTML messages
*
* @param array $arguments Arguments
*
* @internal
*
* @return array
*/
public function parseMode(array $arguments): array
{
if ($arguments['message'] === '' || !isset($arguments['message']) || !isset($arguments['parse_mode'])) {
return $arguments;
@ -594,7 +602,16 @@ trait BotAPI
return $arguments;
}
private function splitToChunks($args)
/**
* Split too long message into chunks
*
* @param array $args Arguments
*
* @internal
*
* @return \Generator
*/
public function splitToChunks($args): \Generator
{
$args = yield $this->parseMode($args);
if (!isset($args['entities'])) {

View File

@ -104,8 +104,34 @@ class Lite
yield $connection->connect($lite);
}
}
/**
* Logger.
*
* @param string $param Parameter
* @param int $level Logging level
* @param string $file File where the message originated
*
* @return void
*/
public function logger($param, int $level = Logger::NOTICE, string $file = ''): void
{
if ($file === null) {
$file = \basename(\debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1)[0]['file'], '.php');
}
public function methodCall(string $methodName, array $args = [], array $aargs = [])
isset($this->logger) ? $this->logger->logger($param, $level, $file) : Logger::$default->logger($param, $level, $file);
}
/**
* Call lite method.
*
* @param string $methodName Method name
* @param array $args Arguments
*
* @return \Generator
*/
public function methodCall(string $methodName, array $args = [], array $aargs = []): \Generator
{
$data = yield $this->TL->serializeMethod($methodName, $args);
$data = yield $this->TL->serializeMethod('liteServer.query', ['data' => $data]);
@ -129,9 +155,9 @@ class Lite
*
* @param array $parameters Parameters
*
* @return void
* @return array
*/
public function botAPItoMTProto(array $parameters)
public function botAPItoMTProto(array $parameters): array
{
return $parameters;
}
@ -139,9 +165,9 @@ class Lite
/**
* Get TL method namespaces.
*
* @return void
* @return array
*/
public function getMethodNamespaces()
public function getMethodNamespaces(): array
{
return $this->TL->getMethodNamespaces();
}

View File

@ -17,6 +17,6 @@ $API->async(true);
$API->loop(
function () use ($API) {
yield $API->connect(__DIR__.'/ton-lite-client-test1.config.json');
\var_dump(yield $API->liteServer->getTime());
$API->logger(yield $API->liteServer->getTime());
}
);