Skip to content

Commit

Permalink
Fix etag hash generation, update to layer 186
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Aug 15, 2024
1 parent 29057d3 commit fbeebaa
Show file tree
Hide file tree
Showing 13 changed files with 174 additions and 84 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1150,16 +1150,21 @@ Some of MadelineProto's core components are also available as separate, standalo
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.getSavedReactionTags.html" name="messages.getSavedReactionTags">messages.getSavedReactionTags</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.reorderQuickReplies.html" name="messages.reorderQuickReplies">messages.reorderQuickReplies</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.requestMainWebView.html" name="messages.requestMainWebView">messages.requestMainWebView</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendPaidReaction.html" name="messages.sendPaidReaction">messages.sendPaidReaction</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.sendQuickReplyMessages.html" name="messages.sendQuickReplyMessages">messages.sendQuickReplyMessages</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.toggleDialogFilterTags.html" name="messages.toggleDialogFilterTags">messages.toggleDialogFilterTags</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.togglePaidReactionPrivacy.html" name="messages.togglePaidReactionPrivacy">messages.togglePaidReactionPrivacy</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/messages.updateSavedReactionTag.html" name="messages.updateSavedReactionTag">messages.updateSavedReactionTag</a>
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#rleDecode" name="rleDecode">null-byte RLE decode: rleDecode</a>
* <a href="https://docs.madelineproto.xyz/PHP/danog/MadelineProto/API.html#rleEncode" name="rleEncode">null-byte RLE encode: rleEncode</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.changeStarsSubscription.html" name="payments.changeStarsSubscription">payments.changeStarsSubscription</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.fulfillStarsSubscription.html" name="payments.fulfillStarsSubscription">payments.fulfillStarsSubscription</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsGiftOptions.html" name="payments.getStarsGiftOptions">payments.getStarsGiftOptions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsRevenueAdsAccountUrl.html" name="payments.getStarsRevenueAdsAccountUrl">payments.getStarsRevenueAdsAccountUrl</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsRevenueStats.html" name="payments.getStarsRevenueStats">payments.getStarsRevenueStats</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsRevenueWithdrawalUrl.html" name="payments.getStarsRevenueWithdrawalUrl">payments.getStarsRevenueWithdrawalUrl</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsStatus.html" name="payments.getStarsStatus">payments.getStarsStatus</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsSubscriptions.html" name="payments.getStarsSubscriptions">payments.getStarsSubscriptions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsTopupOptions.html" name="payments.getStarsTopupOptions">payments.getStarsTopupOptions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsTransactions.html" name="payments.getStarsTransactions">payments.getStarsTransactions</a>
* <a href="https://docs.madelineproto.xyz/API_docs/methods/payments.getStarsTransactionsByID.html" name="payments.getStarsTransactionsByID">payments.getStarsTransactionsByID</a>
Expand Down
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 44 files
+2 −1 docs/API_docs/constructors/botInfo.md
+3 −1 docs/API_docs/constructors/channel.md
+27 −0 docs/API_docs/constructors/channelAdminLogEventActionToggleSignatureProfiles.md
+2 −1 docs/API_docs/constructors/channelFull.md
+2 −1 docs/API_docs/constructors/channelParticipant.md
+2 −1 docs/API_docs/constructors/channelParticipantSelf.md
+4 −1 docs/API_docs/constructors/chatInvite.md
+3 −1 docs/API_docs/constructors/chatInviteExported.md
+32 −11 docs/API_docs/constructors/index.md
+27 −0 docs/API_docs/constructors/inputFileStoryDocument.md
+27 −0 docs/API_docs/constructors/inputInvoiceChatInviteSubscription.md
+2 −1 docs/API_docs/constructors/messageReactions.md
+31 −0 docs/API_docs/constructors/messageReactor.md
+5 −2 docs/API_docs/constructors/payments.starsStatus.md
+22 −0 docs/API_docs/constructors/reactionPaid.md
+2 −1 docs/API_docs/constructors/sponsoredMessage.md
+34 −0 docs/API_docs/constructors/starsSubscription.md
+28 −0 docs/API_docs/constructors/starsSubscriptionPricing.md
+3 −1 docs/API_docs/constructors/starsTransaction.md
+1 −1 docs/API_docs/index.md
+25 −5 docs/API_docs/methods/api_index.md
+3 −2 docs/API_docs/methods/channels.toggleSignatures.md
+10 −0 docs/API_docs/methods/index.md
+2 −1 docs/API_docs/methods/messages.exportChatInvite.md
+2 −1 docs/API_docs/methods/messages.getChatInviteImporters.md
+43 −0 docs/API_docs/methods/messages.sendPaidReaction.md
+2 −1 docs/API_docs/methods/messages.setChatAvailableReactions.md
+42 −0 docs/API_docs/methods/messages.togglePaidReactionPrivacy.md
+42 −0 docs/API_docs/methods/payments.changeStarsSubscription.md
+41 −0 docs/API_docs/methods/payments.fulfillStarsSubscription.md
+42 −0 docs/API_docs/methods/payments.getStarsSubscriptions.md
+2 −1 docs/API_docs/methods/payments.getStarsTransactions.md
+2 −0 docs/API_docs/types/ChannelAdminLogEventAction.md
+2 −0 docs/API_docs/types/InputFile.md
+2 −0 docs/API_docs/types/InputInvoice.md
+21 −0 docs/API_docs/types/MessageReactor.md
+2 −0 docs/API_docs/types/Reaction.md
+21 −0 docs/API_docs/types/StarsSubscription.md
+21 −0 docs/API_docs/types/StarsSubscriptionPricing.md
+2 −0 docs/API_docs/types/Updates.md
+6 −0 docs/API_docs/types/index.md
+2 −0 docs/API_docs/types/payments.StarsStatus.md
+1 −1 docs/docs/USING_METHODS.md
+5 −0 docs/index.md
2 changes: 1 addition & 1 deletion schemas
Submodule schemas updated 1 files
+2,533 −0 TL_telegram_v186.tl
15 changes: 8 additions & 7 deletions src/Namespace/Channels.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Namespace/Help.php

Large diffs are not rendered by default.

77 changes: 51 additions & 26 deletions src/Namespace/Messages.php

Large diffs are not rendered by default.

50 changes: 42 additions & 8 deletions src/Namespace/Payments.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Namespace/Stats.php

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions src/Namespace/Stories.php

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Settings/TLSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ final class TLSchema extends SettingsAbstract
/**
* TL layer version.
*/
protected int $layer = 185;
protected int $layer = 186;
/**
* API schema path.
*/
protected string $APISchema = __DIR__ . '/../TL_telegram_v185.tl';
protected string $APISchema = __DIR__ . '/../TL_telegram_v186.tl';
/**
* MTProto schema path.
*/
Expand Down
49 changes: 32 additions & 17 deletions src/TL_telegram_v185.tl → src/TL_telegram_v186.tl

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions src/Tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,30 @@ public static function convertJsonTL(array $input): array
array_walk($input, $cb);
return $input;
}
private static function uRShift(int $a, int $b): int
{
if($b == 0) {
return $a;
}
return ($a >> $b) & ~(1<<(8*PHP_INT_SIZE-1)>>($b-1));
}
/**
* Generate MTProto vector hash.
*
* Returns a vector hash.
*
* @param array $longs IDs
* @param array<string|int> $longs IDs
*/
public static function genVectorHash(array $longs): string
{
$hash = 0;
foreach ($longs as $long) {
$hash ^= $hash >> 21;
if (\is_string($long)) {
$long = self::unpackSignedLong(strrev(substr(md5($long, true), 0, 8)));
}
$hash ^= self::uRShift($hash, 21);
$hash ^= $hash << 35;
$hash ^= $hash >> 4;
$hash ^= self::uRShift($hash, 4);
$hash = $hash + $long;
}
return self::packSignedLong($hash);
Expand Down
2 changes: 1 addition & 1 deletion tools/DocsBuilder/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function mkMethods(): void
if ($param['name'] === 'hash' && ($param['type'] === 'long' || $param['type'] === 'int')) {
$param['pow'] = 'hi';
$param['type'] = 'Vector t';
$param['subtype'] = 'long';
$param['subtype'] = 'long|string';
}
$ptype = $param[$type_or_subtype = isset($param['subtype']) ? 'subtype' : 'type'];
switch ($ptype) {
Expand Down

0 comments on commit fbeebaa

Please sign in to comment.