This commit is contained in:
Daniil Gentili 2017-05-20 14:46:05 +01:00
parent f4155bc3a7
commit 1f18cf6ab9
2 changed files with 12 additions and 5 deletions

View File

@ -18,12 +18,12 @@ $uMadelineProto = false;
try {
$MadelineProto = \danog\MadelineProto\Serialization::deserialize('pipesbot.madeline');
} catch (\danog\MadelineProto\Exception $e) {
\danog\MadelineProto\Logger::log([$e->getMessage()]);
var_dump($e->getMessage());
}
try {
$uMadelineProto = \danog\MadelineProto\Serialization::deserialize('pwr.madeline');
} catch (\danog\MadelineProto\Exception $e) {
\danog\MadelineProto\Logger::log([$e->getMessage()]);
var_dump($e->getMessage());
}
if (file_exists('token.php') && $MadelineProto === false) {
include_once 'token.php';
@ -108,6 +108,7 @@ while (true) {
$updates = $MadelineProto->API->get_updates(['offset' => $offset, 'limit' => 50, 'timeout' => 0]); // Just like in the bot API, you can specify an offset, a limit and a timeout
foreach ($updates as $update) {
$offset = $update['update_id'] + 1; // Just like in the bot API, the offset must be set to the last update_id
try {
switch ($update['update']['_']) {
case 'updateNewMessage':
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
@ -217,6 +218,8 @@ while (true) {
}
}
}
} catch (\danog\MadelineProto\RPCErrorException $e) {}
}
\danog\MadelineProto\Serialization::serialize('pipesbot.madeline', $MadelineProto);
\danog\MadelineProto\Serialization::serialize('pwr.madeline', $uMadelineProto);

View File

@ -414,7 +414,6 @@ trait BotAPI
if (preg_match('|:new|', substr($href, -4))) {
$entities['buttons'][] = ['_' => 'keyboardButtonUrl', 'text' => $text, 'url' => str_replace('buttonurl:', '', str_replace(':new', '', $href)), 'new' => true];
} else {
var_dump(true);
$entities['buttons'][] = ['_' => 'keyboardButtonUrl', 'text' => $text, 'url' => str_replace('buttonurl:', '', $href)];
}
break;
@ -468,7 +467,12 @@ trait BotAPI
public function split_to_chunks($text)
{
$total_length = 4096;
$text_arr = $this->multipleExplodeKeepDelimiters(["\n"], $text);
$text_arr = [];
foreach ($this->multipleExplodeKeepDelimiters(["\n"], $text) as $word) {
if (strlen($word) > 4096) {
foreach (str_split($word, 4096) as $vv) { $text_arr []= $vv; }
} else $text_arr []= $word;
}
$i = 0;
$message[0] = '';
foreach ($text_arr as $word) {
@ -497,7 +501,7 @@ trait BotAPI
$finalArray = [];
foreach ($initialArray as $item) {
if (strlen($item) > 0) {
array_push($finalArray, $item.$string[strpos($string, $item) + strlen($item)]);
$finalArray []= $item.$string[strpos($string, $item)+strlen($item)];
}
}