mirror of
https://github.com/danog/MadelineProto.git
synced 2024-11-30 10:38:59 +01:00
Written documentation for get_pwr_chat and fixed some bugs
This commit is contained in:
parent
90810ecda1
commit
4e4abed790
@ -437,6 +437,8 @@ var_dump($authorization);
|
|||||||
|
|
||||||
See tests/testing.php for more examples.
|
See tests/testing.php for more examples.
|
||||||
|
|
||||||
|
Use `get_pwr_chat` to get chat info, see [here for the parameters and the result](https://daniil.it/MadelineProto/get_pwr_chat.html).
|
||||||
|
|
||||||
Methods that allow sending message entities (messages.sendMessage for example) also have an additional parse_mode parameter that enables or disables html/markdown parsing of the message to be sent. See the method-specific documentation for more info.
|
Methods that allow sending message entities (messages.sendMessage for example) also have an additional parse_mode parameter that enables or disables html/markdown parsing of the message to be sent. See the method-specific documentation for more info.
|
||||||
|
|
||||||
To convert the results of methods to bot API objects you must provide a second parameter to method wrappers, containing an array with the `botAPI` key set to true.
|
To convert the results of methods to bot API objects you must provide a second parameter to method wrappers, containing an array with the `botAPI` key set to true.
|
||||||
|
46
docs/Chat.md
Normal file
46
docs/Chat.md
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
---
|
||||||
|
title: PWRTelegram chat
|
||||||
|
description: chat attributes, type and example
|
||||||
|
---
|
||||||
|
## Constructor: PWRTelegram chat
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Attributes:
|
||||||
|
|
||||||
|
| Name | Type | Required |Description|
|
||||||
|
|----------|:-------------:|:--------:|----------:|
|
||||||
|
|type|[string](../types/string.md) | Yes|bot, user, channel, supergroup or chat|
|
||||||
|
|id|[long](../types/long.md) | Yes|bot API chat id|
|
||||||
|
|access\_hash|[long](../types/long.md) | Yes|access hash of peer|
|
||||||
|
|first\_name|[string](../types/string.md) | Yes|First name of the user|
|
||||||
|
|last\_name|[string](../types/string.md) | Optional|Last name of the user|
|
||||||
|
|username|[string](../types/string.md) | Optional|Username|
|
||||||
|
|verified|[Bool](../types/Bool.md) | Optional|Is the peer official?|
|
||||||
|
|restricted|[Bool](../types/Bool.md) | Optional|Is the peer restricted to the current user?|
|
||||||
|
|restriction\_reason|[string](../types/string.md) | Optional|Restriction reason|
|
||||||
|
|status|[UserStatus](../types/UserStatus.md) | Optional|Describes last time user was online|
|
||||||
|
|bot\_inline\_placeholder|[string](../types/string.md) | Optional|Inline placeholder of inline bot|
|
||||||
|
|about|[string](../types/string.md) | Optional|Description of supergroups/channels or bios of users|
|
||||||
|
|bot\_info|[BotInfo](../types/BotInfo.md) | Optional|Bot info of bots|
|
||||||
|
|phone\_calls\_available|[Bool](../types/Bool.md) | Optional|Are phone calls available for that user?|
|
||||||
|
|phone\_calls\_private|[Bool](../types/Bool.md) | Optional||
|
||||||
|
|common\_chats\_count|[int](../types/int.md) | Yes|Number of chats in common with that user|
|
||||||
|
|photo|[string](../types/string.md) | Optional|bot API file id of the profile picture|
|
||||||
|
|title|[string](../types/string.md) | Optional|Chat title|
|
||||||
|
|participants\_count|[int](../types/int.md) | Optional|Number of participants in the chat.|
|
||||||
|
|kicked\_count|[int](../types/int.md) | Optional|Number of users kicked from the chat.|
|
||||||
|
|admin\_count|[int](../types/int.md) | Optional|Number of admins in the chat.|
|
||||||
|
|admin|[Bool](../types/Bool.md) | Optional|Are you an admin in this chat?|
|
||||||
|
|all\_members\_are\_administrators|[Bool](../types/Bool.md) | Optional|True if a group has ‘All Members Are Admins’ enabled.|
|
||||||
|
|invite|[string](../types/string.md) | Optional|Invite link of the chat|
|
||||||
|
|participants|Array of [Participant](Participant.md) | Yes|Chat participants|
|
||||||
|
|democracy|[Bool](../types/Bool.md) | Optional|Can everyone add users to this chat?|
|
||||||
|
|signatures|[Bool](../types/Bool.md) | Optional|Are channel signatures enabled?|
|
||||||
|
|can\_view\_participants|[Bool](../types/Bool.md) | Optional|Can you view participants (you can still view the bots in channels even if this is false)|
|
||||||
|
|can\_set\_username|[Bool](../types/Bool.md) | Optional|Can you set the username of this channel/supergroup?|
|
||||||
|
|migrated\_from\_chat\_id|[int](../types/int.md) | Optional|MTProto chat id of the original chat (render it negative to make it a bot API chat id)|
|
||||||
|
|migrated\_from\_max\_id|[int](../types/int.md) | Optional|Last message id before migration|
|
||||||
|
|pinned\_msg\_id|[int](../types/int.md) | Optional|Message id of pinned message|
|
||||||
|
|
||||||
|
|
17
docs/Participant.md
Normal file
17
docs/Participant.md
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
---
|
||||||
|
title: Participant
|
||||||
|
description: PWRTelegram participant attributes, type and example
|
||||||
|
---
|
||||||
|
## Constructor: PWRTelegram chat participant
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### Attributes:
|
||||||
|
|
||||||
|
| Name | Type | Required | Description|
|
||||||
|
|----------|:-------------:|:--------:|-----------:|
|
||||||
|
|user|[Chat](Chat.md) | Yes| The participant|
|
||||||
|
|inviter|[Chat](Chat.md) | Optional|The user that invited this participant|
|
||||||
|
|date|[int](../types/int.md) | Yes|When was the user invited|
|
||||||
|
|role|[string](../types/int.md) | Yes|user, admin, creator, moderator, editor, creator, kicked|
|
||||||
|
|
43
docs/get_pwr_chat.md
Normal file
43
docs/get_pwr_chat.md
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
---
|
||||||
|
title: get_pwr_chat
|
||||||
|
description: get_pwr_chat parameters, return type and example
|
||||||
|
---
|
||||||
|
## Method: get_pwr_chat
|
||||||
|
|
||||||
|
|
||||||
|
### Parameters:
|
||||||
|
|
||||||
|
| Name | Type |
|
||||||
|
|----------|:-------------:|
|
||||||
|
|id| A username, a bot API chat id, a tg-cli chat id, a [Chat](API_docs/types/Chat.md), a [User](API_docs/types/User.md), an [InputPeer](API_docs/types/InputPeer.md), a [Peer](API_docs/types/Peer.md), or a [Chat](API_docs/types/Chat.md) object|
|
||||||
|
|fullfetch| Optional, a boolean that if set to true (the default) fetches full info (chat photo, invite link, bot info, common_chats_count, phone_calls_available, phone_calls_private, can_set_username, can_view_participants, participants)|
|
||||||
|
|
||||||
|
### Return type: [PWRTelegram Chat](Chat.md)
|
||||||
|
|
||||||
|
### Example:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
$MadelineProto = new \danog\MadelineProto\API();
|
||||||
|
if (isset($token)) {
|
||||||
|
$this->bot_login($token);
|
||||||
|
}
|
||||||
|
if (isset($number)) {
|
||||||
|
$sentCode = $MadelineProto->phone_login($number);
|
||||||
|
echo 'Enter the code you received: ';
|
||||||
|
$code = '';
|
||||||
|
for ($x = 0; $x < $sentCode['type']['length']; $x++) {
|
||||||
|
$code .= fgetc(STDIN);
|
||||||
|
}
|
||||||
|
$MadelineProto->complete_phone_login($code);
|
||||||
|
}
|
||||||
|
|
||||||
|
$Chat = $MadelineProto->get_pwr_chat($id);
|
||||||
|
```
|
||||||
|
|
||||||
|
Or, if you're into Lua:
|
||||||
|
|
||||||
|
```
|
||||||
|
Chat = get_pwr_chat(id)
|
||||||
|
```
|
||||||
|
|
@ -441,6 +441,8 @@ var_dump($authorization);
|
|||||||
|
|
||||||
See tests/testing.php for more examples.
|
See tests/testing.php for more examples.
|
||||||
|
|
||||||
|
Use `get_pwr_chat` to get chat info, see [here for the parameters and the result](https://daniil.it/MadelineProto/get_pwr_chat.html).
|
||||||
|
|
||||||
Methods that allow sending message entities (messages.sendMessage for example) also have an additional parse_mode parameter that enables or disables html/markdown parsing of the message to be sent. See the method-specific documentation for more info.
|
Methods that allow sending message entities (messages.sendMessage for example) also have an additional parse_mode parameter that enables or disables html/markdown parsing of the message to be sent. See the method-specific documentation for more info.
|
||||||
|
|
||||||
To convert the results of methods to bot API objects you must provide a second parameter to method wrappers, containing an array with the `botAPI` key set to true.
|
To convert the results of methods to bot API objects you must provide a second parameter to method wrappers, containing an array with the `botAPI` key set to true.
|
||||||
|
@ -96,7 +96,7 @@ class API extends APIFactory
|
|||||||
{
|
{
|
||||||
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
|
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);
|
||||||
$this->setup_threads();
|
$this->setup_threads();
|
||||||
if (!isset($this->messages)) {
|
if (!isset($this->bots) || $this->bots === null) {
|
||||||
$this->APIFactory();
|
$this->APIFactory();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,9 @@ class MTProto
|
|||||||
$this->reset_session();
|
$this->reset_session();
|
||||||
if (!isset($this->v) || $this->v !== $this->getV()) {
|
if (!isset($this->v) || $this->v !== $this->getV()) {
|
||||||
\danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING);
|
\danog\MadelineProto\Logger::log(['Serialization is out of date, reconstructing object!'], Logger::WARNING);
|
||||||
$this->__construct($this->settings);
|
$settings = $this->settings;
|
||||||
|
unset($settings['tl_schema']);
|
||||||
|
$this->__construct($settings);
|
||||||
}
|
}
|
||||||
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
|
$this->datacenter->__construct($this->settings['connection'], $this->settings['connection_settings']);
|
||||||
if ($this->authorized && $this->settings['updates']['handle_updates']) {
|
if ($this->authorized && $this->settings['updates']['handle_updates']) {
|
||||||
|
@ -322,6 +322,15 @@ trait PeerHandler
|
|||||||
if (isset($full['full']['bot_info'])) {
|
if (isset($full['full']['bot_info'])) {
|
||||||
$res['bot_info'] = $full['full']['bot_info'];
|
$res['bot_info'] = $full['full']['bot_info'];
|
||||||
}
|
}
|
||||||
|
if (isset($full['full']['phone_calls_available'])) {
|
||||||
|
$res['phone_calls_available'] = $full['full']['phone_calls_available'];
|
||||||
|
}
|
||||||
|
if (isset($full['full']['phone_calls_private'])) {
|
||||||
|
$res['phone_calls_private'] = $full['full']['phone_calls_private'];
|
||||||
|
}
|
||||||
|
if (isset($full['full']['common_chats_count'])) {
|
||||||
|
$res['common_chats_count'] = $full['full']['common_chats_count'];
|
||||||
|
}
|
||||||
if (isset($full['full']['profile_photo']['sizes'])) {
|
if (isset($full['full']['profile_photo']['sizes'])) {
|
||||||
$res['photo'] = $this->photosize_to_botapi(end($full['full']['profile_photo']['sizes']), []);
|
$res['photo'] = $this->photosize_to_botapi(end($full['full']['profile_photo']['sizes']), []);
|
||||||
}
|
}
|
||||||
@ -343,6 +352,7 @@ trait PeerHandler
|
|||||||
$res[$key] = $full['Chat'][$key];
|
$res[$key] = $full['Chat'][$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($res['admins_enabled'])) $res['all_members_are_administrators']= $res['admins_enabled'];
|
||||||
|
|
||||||
if (isset($full['full']['chat_photo']['sizes'])) {
|
if (isset($full['full']['chat_photo']['sizes'])) {
|
||||||
$res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), []);
|
$res['photo'] = $this->photosize_to_botapi(end($full['full']['chat_photo']['sizes']), []);
|
||||||
@ -432,7 +442,7 @@ trait PeerHandler
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'channelParticipantEditor':
|
case 'channelParticipantEditor':
|
||||||
$newres['role'] = 'moderator';
|
$newres['role'] = 'editor';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'channelParticipantCreator':
|
case 'channelParticipantCreator':
|
||||||
|
@ -340,9 +340,6 @@ trait TL
|
|||||||
if ($constructorData['predicate'] === 'messageEntityMentionName') {
|
if ($constructorData['predicate'] === 'messageEntityMentionName') {
|
||||||
$constructorData = $this->constructors->find_by_predicate('inputMessageEntityMentionName');
|
$constructorData = $this->constructors->find_by_predicate('inputMessageEntityMentionName');
|
||||||
}
|
}
|
||||||
if ($constructorData['predicate'] === 'dataJSON') {
|
|
||||||
$object['data'] = json_encode($object['data']);
|
|
||||||
}
|
|
||||||
if (!$bare) {
|
if (!$bare) {
|
||||||
$concat .= \danog\PHP\Struct::pack('<i', $constructorData['id']);
|
$concat .= \danog\PHP\Struct::pack('<i', $constructorData['id']);
|
||||||
}
|
}
|
||||||
@ -423,6 +420,10 @@ trait TL
|
|||||||
if (!is_array($arguments[$current_argument['name']]) && $current_argument['type'] === 'InputEncryptedChat') {
|
if (!is_array($arguments[$current_argument['name']]) && $current_argument['type'] === 'InputEncryptedChat') {
|
||||||
$arguments[$current_argument['name']] = $this->secret_chats[$arguments[$current_argument['name']]]['InputEncryptedChat'];
|
$arguments[$current_argument['name']] = $this->secret_chats[$arguments[$current_argument['name']]]['InputEncryptedChat'];
|
||||||
}
|
}
|
||||||
|
if ($current_argument['type'] === 'DataJSON') {
|
||||||
|
$arguments[$current_argument['name']] = ['_' => 'dataJSON', 'data' => json_encode($arguments[$current_argument['name']])];
|
||||||
|
}
|
||||||
|
|
||||||
//\danog\MadelineProto\Logger::log(['Serializing '.$current_argument['name'].' of type '.$current_argument['type']);
|
//\danog\MadelineProto\Logger::log(['Serializing '.$current_argument['name'].' of type '.$current_argument['type']);
|
||||||
$serialized .= $this->serialize_object($current_argument, $arguments[$current_argument['name']], $layer);
|
$serialized .= $this->serialize_object($current_argument, $arguments[$current_argument['name']], $layer);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user