diff --git a/README.md b/README.md
index acae35c3..cb3c72b1 100644
--- a/README.md
+++ b/README.md
@@ -65,6 +65,7 @@ This library can also be used to create lua telegram bots (like bot API bots, on
* PFS in secret chats
+* [Clickable inline buttons](#inline-buttons)!
## PHP Requirements
@@ -174,6 +175,27 @@ You can find examples for nearly every MadelineProto function in
* [`userbots/MadelineProto_bot.php`](https://github.com/danog/MadelineProto/blob/master/userbots/MadelineProto_bot.php) - More fun shiz
* [`userbots/pwrtelegram_debug_bot`](https://github.com/danog/MadelineProto/blob/master/userbots/pwrtelegram_debug_bot.php) - More fun shiz
+### Inline buttons
+
+You can easily click inline buttons using MadelineProto, just access the correct button:
+
+```
+$button = $update['update']['message']['reply_markup']['rows'][0]['buttons'][0];
+```
+
+You can then access properties (they vary depending on the [type of button](https://docs.madelineproto.xyz/API_docs/types/KeyboardButton.html)):
+
+```
+$text = $button['text'];
+```
+
+And click them:
+
+```
+$button->click();
+```
+
+
### Storing sessions
To store information about an account session, serialization must be done.
diff --git a/src/danog/MadelineProto/API.php b/src/danog/MadelineProto/API.php
index 763227ab..4ecd3cfc 100644
--- a/src/danog/MadelineProto/API.php
+++ b/src/danog/MadelineProto/API.php
@@ -72,8 +72,6 @@ class API extends APIFactory
$this->API = $unserialized->API;
$this->APIFactory();
}
- Serialization::$instances[spl_object_hash($unserialized)] = $unserialized;
-
return;
}
$this->API = new MTProto($params);
@@ -85,13 +83,11 @@ class API extends APIFactory
//\danog\MadelineProto\Logger::log(['Getting future salts...'], Logger::ULTRA_VERBOSE);
//$this->future_salts = $this->get_future_salts(['num' => 3]);
\danog\MadelineProto\Logger::log([\danog\MadelineProto\Lang::$current_lang['madelineproto_ready']], Logger::NOTICE);
- Serialization::$instances[spl_object_hash($this)] = $this;
}
public function __wakeup()
{
//if (method_exists($this->API, 'wakeup')) $this->API = $this->API->wakeup();
- Serialization::$instances[spl_object_hash($this)] = $this;
$this->APIFactory();
}
diff --git a/src/danog/MadelineProto/Connection.php b/src/danog/MadelineProto/Connection.php
index 0e8aa753..9fa4b422 100644
--- a/src/danog/MadelineProto/Connection.php
+++ b/src/danog/MadelineProto/Connection.php
@@ -143,7 +143,6 @@ class Connection
break;
case 'http':
case 'https':
- case 'https_proxied':
$this->parsed = parse_url($ip);
if ($this->parsed['host'][0] === '[') {
$this->parsed['host'] = substr($this->parsed['host'], 1, -1);
@@ -161,10 +160,6 @@ class Connection
throw new Exception(\danog\MadelineProto\Lang::$current_lang['socket_con_error']);
}
$this->sock->setBlocking(true);
- if ($this->protocol === 'https_proxied') {
- $this->write("CONNECT {$this->parsed['host']}:$port HTTP/1.1\r\nHost: {$this->parsed['host']}:$port\r\n\r\n");
- $this->read_message();
- }
break;
case 'udp':
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
@@ -182,7 +177,6 @@ class Connection
case 'tcp_full':
case 'http':
case 'https':
- case 'https_proxied':
case 'obfuscated2':
try {
unset($this->sock);
@@ -237,7 +231,6 @@ class Connection
case 'tcp_full':
case 'http':
case 'https':
- case 'https_proxied':
$wrote = 0;
if (($wrote += $this->sock->write($what)) !== $length) {
while (($wrote += $this->sock->write(substr($what, $wrote))) !== $length) {
@@ -282,7 +275,6 @@ class Connection
case 'tcp_full':
case 'http':
case 'https':
- case 'https_proxied':
$packet = '';
while (strlen($packet) < $length) {
$packet .= $this->sock->read($length - strlen($packet));
@@ -331,9 +323,9 @@ class Connection
return $this->read($packet_length < 127 ? $packet_length << 2 : unpack('V', $this->read(3)."\0")[1] << 2);
case 'http':
case 'https':
- case 'https_proxied':
$response = $this->read_http_payload();
if ($response['code'] !== 200) {
+ Logger::log([$response['body']]);
throw new Exception($response['description'], $response['code']);
}
$close = $response['protocol'] === 'HTTP/1.0';
@@ -374,8 +366,7 @@ class Connection
break;
case 'http':
case 'https':
- case 'https_proxied':
- $this->write('POST '.$this->parsed['path']." HTTP/1.1\r\nHost: ".$this->parsed['host']."\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: keep-alive\r\nKeep-Alive: timeout=100000, max=10000000\r\nContent-Length: ".strlen($message)."\r\n\r\n".$message);
+ $this->write('POST '.$this->parsed['path']." HTTP/1.1\r\nHost: ".$this->parsed['host'].":$port\r\nContent-Type: application/x-www-form-urlencoded\r\nConnection: keep-alive\r\nKeep-Alive: timeout=100000, max=10000000\r\nContent-Length: ".strlen($message)."\r\n\r\n".$message);
break;
case 'udp':
throw new Exception(\danog\MadelineProto\Lang::$current_lang['protocol_not_implemented']);
diff --git a/src/danog/MadelineProto/DocsBuilder.php b/src/danog/MadelineProto/DocsBuilder.php
index 9f1ed199..cac1e11d 100644
--- a/src/danog/MadelineProto/DocsBuilder.php
+++ b/src/danog/MadelineProto/DocsBuilder.php
@@ -160,6 +160,7 @@ $result = $'.$type.'->click();
* `false` - If the button is an unsupported button, like keyboardButtonRequestPhone, keyboardButtonRequestGeoLocation, keyboardButtonSwitchInlinekeyboardButtonBuy; you will have to parse data from these buttons manually
+You can also access the properties of the constructor as a normal array, for example $button[\'name\']
';
}
}
diff --git a/src/danog/MadelineProto/Serialization.php b/src/danog/MadelineProto/Serialization.php
index 10f863ee..0d0dbafd 100644
--- a/src/danog/MadelineProto/Serialization.php
+++ b/src/danog/MadelineProto/Serialization.php
@@ -18,8 +18,6 @@ namespace danog\MadelineProto;
*/
class Serialization
{
- public static $instances = [];
-
public static function serialize_all($exception)
{
echo $exception.PHP_EOL;
@@ -134,7 +132,6 @@ class Serialization
if ($unserialized instanceof \danog\MadelineProto\API) {
$unserialized->session = $filename;
}
- self::$instances[spl_object_hash($unserialized)] = $unserialized;
return $unserialized;
}
diff --git a/src/danog/MadelineProto/TL/Types/Button.php b/src/danog/MadelineProto/TL/Types/Button.php
index 0025f398..8f2880ef 100644
--- a/src/danog/MadelineProto/TL/Types/Button.php
+++ b/src/danog/MadelineProto/TL/Types/Button.php
@@ -13,7 +13,7 @@ If not, see .
namespace danog\MadelineProto\TL\Types;
-class Button extends \Volatile implements \JsonSerializable
+class Button implements \JsonSerializable, \ArrayAccess
{
use \danog\Serializable;
private $info = [];
@@ -57,4 +57,20 @@ class Button extends \Volatile implements \JsonSerializable
{
return (array) $this->data;
}
+ public function offsetSet($name, $value) {
+ if ($name === null) {
+ $this->data []= $value;
+ } else {
+ $this->data[$name] = $value;
+ }
+ }
+ public function offsetGet($name) {
+ return $this->data[$name];
+ }
+ public function offsetUnset($name) {
+ unset($this->data[$name]);
+ }
+ public function offsetExists($name) {
+ return isset($this->data[$name]);
+ }
}
diff --git a/tests/makephar.sh b/tests/makephar.sh
index 94ccbe5b..b3607b54 100755
--- a/tests/makephar.sh
+++ b/tests/makephar.sh
@@ -46,9 +46,9 @@ git add -A
git commit -am "Release $TRAVIS_COMMIT"
git push origin master
cd ..
+echo "$TRAVIS_COMMIT_MESSAGE" | grep "Apply fixes from StyleCI" && exit
[ -d JSON.sh ] || git clone https://github.com/dominictarr/JSON.sh
-
for chat_id in $destinations;do
ID=$(curl -s https://api.telegram.org/bot$token/sendMessage -F disable_web_page_preview=1 -F text=" Recent Commits to MadelineProto:master
$TRAVIS_COMMIT_MESSAGE