This commit is contained in:
Daniil Gentili 2017-05-22 14:03:10 +01:00
commit aa6e5e9a20
7 changed files with 76 additions and 22 deletions

14
a.php
View File

@ -1,14 +0,0 @@
<?php
require 'vendor/autoload.php';
class a extends Volatile
{
// public $a = [];
public function __construct()
{
$this->a = 'le';
}
}
$a = new a();
var_dump($a);

View File

@ -27,6 +27,8 @@ try {
die;
}
}
var_dump($MadelineProto->rle_decode($MadelineProto->base64url_decode('gRuWfE2EXVJtaecDLpxYs39tElkZtzLo2mwsdmkuRbZQLO6ofKSoTHedbY1N9lAeUfvgE8wqHIF1VJ95YIyCCLswdZlmf-RWdph_C8wcUeSxtNCTE1gdbmiZp77uIT77bDbUHHbNyfgsKwY30aZS91snXwIrOulsGGA_j7VQ0k9TzGO9AczSj0LZt6kVpPpXKqSraHopH59Tpv4UCX3qXPa5XbcyodpOIL_VN5TtpfEUxoF5asavCOgNj6V4KInLDjkpLr-8dgViLUGRZagxr0EFHUs7DT9dW66_A4_qnszPlIw6GHOIlhLxV8emke0JV_hvATN11uT_RlnHNY83vQ')));
$offset = 0;
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

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,7 +108,8 @@ 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
switch ($update['update']['_']) {
try {
switch ($update['update']['_']) {
case 'updateNewMessage':
if (isset($update['update']['message']['out']) && $update['update']['message']['out']) {
continue;
@ -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

@ -64,6 +64,9 @@ if (!extension_loaded('pthreads')) {
private function runCollectable($idx, Collectable $collectable)
{
$collectable->worker = $this;
if (!isset($collectable->state)) {
$collectable->state = 0;
}
$collectable->state |= THREAD::RUNNING;
$collectable->run();
$collectable->state &= ~THREAD::RUNNING;

View File

@ -60,7 +60,7 @@ class DataCenter extends \Volatile
$test = $this->settings[$dc_config_number]['test_mode'] ? 'test' : 'main';
$ipv6 = $this->settings[$dc_config_number]['ipv6'] ? 'ipv6' : 'ipv4';
$address = $this->dclist[$test][$ipv6][$dc_number]['ip_address'];
$address = $this->settings[$dc_config_number]['ipv6'] ? '['.$address.']' : $address;
//$address = $this->settings[$dc_config_number]['ipv6'] ? '['.$address.']' : $address;
$port = $this->dclist[$test][$ipv6][$dc_number]['port'];
if ($this->settings[$dc_config_number]['protocol'] === 'https') {
$subdomain = $this->dclist['ssl_subdomains'][$dc_number];

View File

@ -99,6 +99,14 @@ class MTProto extends \Volatile
private $dialog_params = ['limit' => 0, 'offset_date' => 0, 'offset_id' => 0, 'offset_peer' => ['_' => 'inputPeerEmpty']];
public $storage = [];
private $zero;
private $one;
private $two;
private $three;
private $four;
private $twoe1984;
private $twoe2047;
private $twoe2048;
public function ___construct($settings = [])
{
@ -161,7 +169,7 @@ class MTProto extends \Volatile
public function __sleep()
{
return ['encrypted_layer', 'settings', 'config', 'ipv6', 'should_serialize', 'authorization', 'authorized', 'login_temp_status', 'bigint', 'run_workers', 'threads', 'rsa_keys', 'last_recv', 'dh_config', 'chats', 'last_stored', 'qres', 'pending_updates', 'bad_msg_error_codes', 'msgs_info_flags', 'stop', 'updates_state', 'got_state', 'channels_state', 'updates', 'updates_key', 'getting_state', 'full_chats', 'msg_ids', 'dialog_params', 'storage', 'datacenter'];
return ['encrypted_layer', 'settings', 'config', 'ipv6', 'should_serialize', 'authorization', 'authorized', 'login_temp_status', 'bigint', 'run_workers', 'threads', 'rsa_keys', 'last_recv', 'dh_config', 'chats', 'last_stored', 'qres', 'pending_updates', 'bad_msg_error_codes', 'msgs_info_flags', 'stop', 'updates_state', 'got_state', 'channels_state', 'updates', 'updates_key', 'getting_state', 'full_chats', 'msg_ids', 'dialog_params', 'storage', 'datacenter', 'v', 'constructors', 'td_constructors', 'methods', 'td_methods', 'td_descriptions', 'twoe1984', 'twoe2047', 'twoe2048', 'zero', 'one', 'two', 'three', 'four'];
}
public function __wakeup()
@ -605,7 +613,7 @@ class MTProto extends \Volatile
public function getV()
{
return 32;
return 34;
}
public function get_self()

View File

@ -407,6 +407,16 @@ trait BotAPI
$href = $node->getAttribute('href');
if (preg_match('|mention:|', $href)) {
$entities[] = ['_' => 'inputMessageEntityMentionName', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text), 'user_id' => $this->get_info(str_replace('mention:', '', $href))['InputUser']];
} elseif (preg_match('|buttonurl:|', $href)) {
if (!isset($entities['buttons'])) {
$entities['buttons'] = [];
}
if (preg_match('|:new|', substr($href, -4))) {
$entities['buttons'][] = ['_' => 'keyboardButtonUrl', 'text' => $text, 'url' => str_replace('buttonurl:', '', str_replace(':new', '', $href)), 'new' => true];
} else {
$entities['buttons'][] = ['_' => 'keyboardButtonUrl', 'text' => $text, 'url' => str_replace('buttonurl:', '', $href)];
}
break;
} else {
$entities[] = ['_' => 'messageEntityTextUrl', 'offset' => mb_strlen($nmessage), 'length' => mb_strlen($text), 'url' => $href];
}
@ -440,6 +450,10 @@ trait BotAPI
foreach ($dom->getElementsByTagName('body')->item(0)->childNodes as $node) {
$this->parse_node($node, $arguments['entities'], $nmessage);
}
if (isset($arguments['entities']['buttons'])) {
$arguments['reply_markup'] = $this->build_rows($arguments['entities']['buttons']);
unset($arguments['entities']['buttons']);
}
unset($arguments['parse_mode']);
} catch (\DOMException $e) {
} catch (\danog\MadelineProto\Exception $e) {
@ -453,7 +467,16 @@ 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) {
@ -482,7 +505,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)];
}
}
@ -513,4 +536,33 @@ trait BotAPI
return htmlentities($text);
}
}
public function build_rows($button_list)
{
$end = false;
$rows = [];
$buttons = [];
$cols = 0;
foreach ($button_list as $button) {
if (isset($button['new'])) {
if (count($buttons) == 0) {
$buttons[] = $button;
} else {
$row = ['_' => 'keyboardButtonRow', 'buttons' => $buttons];
$rows[] = $row;
$buttons = [$button];
}
} else {
$buttons[] = $button;
$end = true;
}
}
if ($end) {
$row = ['_' => 'keyboardButtonRow', 'buttons' => $buttons];
$rows[] = $row;
}
return ['_' => 'replyInlineMarkup', 'rows' => $rows];
}
}