Skip to content

Commit c690833

Browse files
committed
feat(raw): update tl schema and add new rpc errors
1 parent b6c4bff commit c690833

37 files changed

Lines changed: 1344 additions & 16 deletions

compiler/api/source/main_api.tl

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,43 @@
1-
// https://github.com/telegramdesktop/tdesktop/blob/dev/Telegram/SourceFiles/mtproto/scheme/api.tl
2-
// https://github.com/tdlib/td/blob/master/td/generate/scheme/telegram_api.tl
1+
// === merged.tl generated by fetch-and-merge-tl ===
2+
// source: tdlib/td/td/generate/scheme/telegram_api.tl@8b005a6
3+
// source: telegramdesktop/tdesktop/Telegram/SourceFiles/mtproto/scheme/api.tl@6327bac
4+
// merge strategy: td (primary) order retained; unique lines from tdesktop appended; exact-line de-dup.
5+
// int ? = Int;
6+
// long ? = Long;
7+
// double ? = Double;
8+
// string ? = String;
39

4-
///////////////////////////////
5-
///////// Main application API
6-
///////////////////////////////
10+
// bytes = Bytes;
11+
// int256 = Int256;
712

8-
---types---
13+
// true#3fedd339 = True;
14+
15+
// boolFalse#bc799737 = Bool;
16+
// boolTrue#997275b5 = Bool;
17+
18+
// vector#1cb5c415 {t:Type} # [ t ] = Vector t;
19+
20+
// error#c4b9f9bb code:int text:string = Error;
921

10-
// boolFalse#bc799737 = Bool; // Parsed manually
11-
// boolTrue#997275b5 = Bool; // Parsed manually
22+
ipPort#d433ad73 ipv4:int port:int = IpPort;
23+
ipPortSecret#37982646 ipv4:int port:int secret:bytes = IpPort;
24+
accessPointRule#4679b65f phone_prefix_rules:string dc_id:int ips:vector<IpPort> = AccessPointRule;
25+
help.configSimple#5a592a6c date:int expires:int rules:vector<AccessPointRule> = help.ConfigSimple;
1226

13-
// true#3fedd339 = True; // Not used
27+
inputPeerPhotoFileLocationLegacy#27d69997 flags:# big:flags.0?true peer:InputPeer volume_id:long local_id:int = InputFileLocation;
28+
inputStickerSetThumbLegacy#dbaeae9 stickerset:InputStickerSet volume_id:long local_id:int = InputFileLocation;
1429

15-
// vector#1cb5c415 {t:Type} # [ t ] = Vector t; // Parsed manually
30+
---functions---
31+
32+
test.useConfigSimple = help.ConfigSimple;
33+
test.parseInputAppEvent = InputAppEvent;
1634

17-
// error#c4b9f9bb code:int text:string = Error; // Not used
35+
invokeWithBusinessConnectionPrefix#dd289f8e connection_id:string = Error;
36+
invokeWithGooglePlayIntegrityPrefix#1df92984 nonce:string token:string = Error;
37+
invokeWithApnsSecretPrefix#0dae54f8 nonce:string secret:string = Error;
38+
invokeWithReCaptchaPrefix#adbb0f94 token:string = Error;
1839

19-
// null#56730bcc = Null; // Parsed manually
40+
---types---
2041

2142
inputPeerEmpty#7f3b18ea = InputPeer;
2243
inputPeerSelf#7da07ec9 = InputPeer;
@@ -2919,5 +2940,5 @@ smsjobs.getSmsJob#778d902f job_id:string = SmsJob;
29192940
smsjobs.finishJob#4f1ebf24 flags:# job_id:string error:flags.0?string = Bool;
29202941

29212942
fragment.getCollectibleInfo#be1e85ba collectible:InputCollectible = fragment.CollectibleInfo;
2922-
2923-
// LAYER 223
2943+
null#56730bcc = Null;
2944+
// LAYER 223

pyrogram/errors/exceptions/all.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
# You should have received a copy of the GNU Lesser General Public License
1717
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
1818

19-
count = 771
19+
count = 774
2020

2121
exceptions = {
2222
420: {
@@ -587,9 +587,11 @@
587587
"SRP_A_INVALID": "SrpAInvalid",
588588
"SRP_ID_INVALID": "SrpIdInvalid",
589589
"SRP_PASSWORD_CHANGED": "SrpPasswordChanged",
590+
"STARGIFT_ALREADY_BURNED": "StargiftAlreadyBurned",
590591
"STARGIFT_ALREADY_CONVERTED": "StargiftAlreadyConverted",
591592
"STARGIFT_ALREADY_TRANSFERRED": "StargiftAlreadyTransferred",
592593
"STARGIFT_ALREADY_UPGRADED": "StargiftAlreadyUpgraded",
594+
"STARGIFT_ATTRIBUTE_INVALID": "StargiftAttributeInvalid",
593595
"STARGIFT_CONVERT_TOO_OLD": "StargiftConvertTooOld",
594596
"STARGIFT_EXPORT_UNAVAILABLE": "StargiftExportUnavailable",
595597
"STARGIFT_INVALID": "StargiftInvalid",
@@ -715,6 +717,7 @@
715717
"USER_CHANNELS_TOO_MUCH": "UserChannelsTooMuch",
716718
"USER_CREATOR": "UserCreator",
717719
"USER_GIFT_UNAVAILABLE": "UserGiftUnavailable",
720+
"USER_HANDLE_MISMATCH": "UserHandleMismatch",
718721
"USER_ID_INVALID": "UserIdInvalid",
719722
"USER_INVALID": "UserInvalid",
720723
"USER_IS_BLOCKED": "UserIsBlocked",

pyrogram/errors/exceptions/bad_request_400.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3407,6 +3407,13 @@ class SrpPasswordChanged(BadRequest):
34073407
MESSAGE = __doc__
34083408

34093409

3410+
class StargiftAlreadyBurned(BadRequest):
3411+
"""The provided gift is already burned."""
3412+
ID = "STARGIFT_ALREADY_BURNED"
3413+
"""``str``: RPC Error ID"""
3414+
MESSAGE = __doc__
3415+
3416+
34103417
class StargiftAlreadyConverted(BadRequest):
34113418
"""The provided star gift already converted to stars."""
34123419
ID = "STARGIFT_ALREADY_CONVERTED"
@@ -3428,6 +3435,13 @@ class StargiftAlreadyUpgraded(BadRequest):
34283435
MESSAGE = __doc__
34293436

34303437

3438+
class StargiftAttributeInvalid(BadRequest):
3439+
"""The provided gift attribute is invalid."""
3440+
ID = "STARGIFT_ATTRIBUTE_INVALID"
3441+
"""``str``: RPC Error ID"""
3442+
MESSAGE = __doc__
3443+
3444+
34313445
class StargiftConvertTooOld(BadRequest):
34323446
"""This gift can no longer be converted into stars."""
34333447
ID = "STARGIFT_CONVERT_TOO_OLD"
@@ -4303,6 +4317,13 @@ class UserGiftUnavailable(BadRequest):
43034317
MESSAGE = __doc__
43044318

43054319

4320+
class UserHandleMismatch(BadRequest):
4321+
"""The user handle mismatch."""
4322+
ID = "USER_HANDLE_MISMATCH"
4323+
"""``str``: RPC Error ID"""
4324+
MESSAGE = __doc__
4325+
4326+
43064327
class UserIdInvalid(BadRequest):
43074328
"""The provided user id is invalid."""
43084329
ID = "USER_ID_INVALID"

pyrogram/raw/all.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,16 @@
7676
0xf3427b8c: "pyrogram.raw.functions.PingDelayDisconnect",
7777
0xe7512126: "pyrogram.raw.functions.DestroySession",
7878
0x9a5f6e95: "pyrogram.raw.functions.contest.SaveDeveloperInfo",
79+
0xd433ad73: "pyrogram.raw.functions.IpPort",
80+
0x37982646: "pyrogram.raw.functions.IpPortSecret",
81+
0x4679b65f: "pyrogram.raw.functions.AccessPointRule",
82+
0x5a592a6c: "pyrogram.raw.functions.help.ConfigSimple",
83+
0x27d69997: "pyrogram.raw.functions.InputPeerPhotoFileLocationLegacy",
84+
0xdbaeae9: "pyrogram.raw.functions.InputStickerSetThumbLegacy",
85+
0xdd289f8e: "pyrogram.raw.functions.InvokeWithBusinessConnectionPrefix",
86+
0x1df92984: "pyrogram.raw.functions.InvokeWithGooglePlayIntegrityPrefix",
87+
0x0dae54f8: "pyrogram.raw.functions.InvokeWithApnsSecretPrefix",
88+
0xadbb0f94: "pyrogram.raw.functions.InvokeWithReCaptchaPrefix",
7989
0x7f3b18ea: "pyrogram.raw.types.InputPeerEmpty",
8090
0x7da07ec9: "pyrogram.raw.types.InputPeerSelf",
8191
0x35a95cb9: "pyrogram.raw.types.InputPeerChat",
@@ -2373,6 +2383,7 @@
23732383
0x778d902f: "pyrogram.raw.functions.smsjobs.GetSmsJob",
23742384
0x4f1ebf24: "pyrogram.raw.functions.smsjobs.FinishJob",
23752385
0xbe1e85ba: "pyrogram.raw.functions.fragment.GetCollectibleInfo",
2386+
0x56730bcc: "pyrogram.raw.functions.Null",
23762387
0xbc799737: "pyrogram.raw.core.BoolFalse",
23772388
0x997275b5: "pyrogram.raw.core.BoolTrue",
23782389
0x1cb5c415: "pyrogram.raw.core.Vector",

pyrogram/raw/base/access_point_rule.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class AccessPointRule(metaclass=BaseTypeMeta): # type: ignore
4040
:columns: 2
4141
4242
- :obj:`AccessPointRule <pyrogram.raw.types.AccessPointRule>`
43+
44+
See Also:
45+
This object can be returned by 1 method:
46+
47+
.. hlist::
48+
:columns: 2
49+
50+
- :obj:`AccessPointRule <pyrogram.raw.functions.AccessPointRule>`
4351
"""
4452

4553
QUALNAME = "pyrogram.raw.base.AccessPointRule"

pyrogram/raw/base/help/config_simple.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ class ConfigSimple(metaclass=BaseTypeMeta): # type: ignore
4040
:columns: 2
4141
4242
- :obj:`help.ConfigSimple <pyrogram.raw.types.help.ConfigSimple>`
43+
44+
See Also:
45+
This object can be returned by 1 method:
46+
47+
.. hlist::
48+
:columns: 2
49+
50+
- :obj:`help.ConfigSimple <pyrogram.raw.functions.help.ConfigSimple>`
4351
"""
4452

4553
QUALNAME = "pyrogram.raw.base.help.ConfigSimple"

pyrogram/raw/base/input_file_location.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,15 @@ class InputFileLocation(metaclass=BaseTypeMeta): # type: ignore
4949
- :obj:`InputSecureFileLocation <pyrogram.raw.types.InputSecureFileLocation>`
5050
- :obj:`InputStickerSetThumb <pyrogram.raw.types.InputStickerSetThumb>`
5151
- :obj:`InputTakeoutFileLocation <pyrogram.raw.types.InputTakeoutFileLocation>`
52+
53+
See Also:
54+
This object can be returned by 2 methods:
55+
56+
.. hlist::
57+
:columns: 2
58+
59+
- :obj:`InputPeerPhotoFileLocationLegacy <pyrogram.raw.functions.InputPeerPhotoFileLocationLegacy>`
60+
- :obj:`InputStickerSetThumbLegacy <pyrogram.raw.functions.InputStickerSetThumbLegacy>`
5261
"""
5362

5463
QUALNAME = "pyrogram.raw.base.InputFileLocation"

pyrogram/raw/base/ip_port.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ class IpPort(metaclass=BaseTypeMeta): # type: ignore
4141
4242
- :obj:`IpPort <pyrogram.raw.types.IpPort>`
4343
- :obj:`IpPortSecret <pyrogram.raw.types.IpPortSecret>`
44+
45+
See Also:
46+
This object can be returned by 2 methods:
47+
48+
.. hlist::
49+
:columns: 2
50+
51+
- :obj:`IpPort <pyrogram.raw.functions.IpPort>`
52+
- :obj:`IpPortSecret <pyrogram.raw.functions.IpPortSecret>`
4453
"""
4554

4655
QUALNAME = "pyrogram.raw.base.IpPort"

pyrogram/raw/functions/__init__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,15 @@
3232
from .ping import Ping
3333
from .ping_delay_disconnect import PingDelayDisconnect
3434
from .destroy_session import DestroySession
35+
from .ip_port import IpPort
36+
from .ip_port_secret import IpPortSecret
37+
from .access_point_rule import AccessPointRule
38+
from .input_peer_photo_file_location_legacy import InputPeerPhotoFileLocationLegacy
39+
from .input_sticker_set_thumb_legacy import InputStickerSetThumbLegacy
40+
from .invoke_with_business_connection_prefix import InvokeWithBusinessConnectionPrefix
41+
from .invoke_with_google_play_integrity_prefix import InvokeWithGooglePlayIntegrityPrefix
42+
from .invoke_with_apns_secret_prefix import InvokeWithApnsSecretPrefix
43+
from .invoke_with_re_captcha_prefix import InvokeWithReCaptchaPrefix
3544
from .invoke_after_msg import InvokeAfterMsg
3645
from .invoke_after_msgs import InvokeAfterMsgs
3746
from .init_connection import InitConnection
@@ -43,4 +52,5 @@
4352
from .invoke_with_google_play_integrity import InvokeWithGooglePlayIntegrity
4453
from .invoke_with_apns_secret import InvokeWithApnsSecret
4554
from .invoke_with_re_captcha import InvokeWithReCaptcha
46-
from . import contest, auth, account, users, contacts, messages, updates, photos, upload, help, channels, bots, payments, stickers, phone, langpack, folders, stats, chatlists, stories, premium, smsjobs, fragment
55+
from .null import Null
56+
from . import contest, help, auth, account, users, contacts, messages, updates, photos, upload, channels, bots, payments, stickers, phone, langpack, folders, stats, chatlists, stories, premium, smsjobs, fragment
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from io import BytesIO
20+
from typing import TYPE_CHECKING, List, Optional, Any
21+
22+
from pyrogram.raw.core.primitives import Int, Long, Int128, Int256, Bool, Bytes, String, Double, Vector
23+
from pyrogram.raw.core import TLObject
24+
25+
if TYPE_CHECKING:
26+
from pyrogram import raw
27+
28+
# # # # # # # # # # # # # # # # # # # # # # # #
29+
# !!! WARNING !!! #
30+
# This is a generated file! #
31+
# All changes made in this file will be lost! #
32+
# # # # # # # # # # # # # # # # # # # # # # # #
33+
34+
35+
class AccessPointRule(TLObject["raw.base.AccessPointRule"]):
36+
"""Telegram API method.
37+
38+
Details:
39+
- Layer: ``223``
40+
- ID: ``4679B65F``
41+
42+
Parameters:
43+
phone_prefix_rules: ``str``
44+
dc_id: ``int`` ``32-bit``
45+
ips: List of :obj:`IpPort <pyrogram.raw.base.IpPort>`
46+
47+
Returns:
48+
:obj:`AccessPointRule <pyrogram.raw.base.AccessPointRule>`
49+
"""
50+
51+
__slots__: List[str] = ["phone_prefix_rules", "dc_id", "ips"]
52+
53+
ID = 0x4679b65f
54+
QUALNAME = "functions.AccessPointRule"
55+
56+
def __init__(self, *, phone_prefix_rules: str, dc_id: int, ips: List["raw.base.IpPort"]) -> None:
57+
self.phone_prefix_rules = phone_prefix_rules # string
58+
self.dc_id = dc_id # int
59+
self.ips = ips # vector<IpPort>
60+
61+
@staticmethod
62+
def read(b: BytesIO, *args: Any) -> "AccessPointRule":
63+
# No flags
64+
65+
phone_prefix_rules = String.read(b)
66+
67+
dc_id = Int.read(b)
68+
69+
ips = TLObject.read(b)
70+
71+
return AccessPointRule(phone_prefix_rules=phone_prefix_rules, dc_id=dc_id, ips=ips)
72+
73+
def write(self, *args) -> bytes:
74+
b = BytesIO()
75+
b.write(Int(self.ID, False))
76+
77+
# No flags
78+
79+
b.write(String(self.phone_prefix_rules))
80+
81+
b.write(Int(self.dc_id))
82+
83+
b.write(Vector(self.ips))
84+
85+
return b.getvalue()

0 commit comments

Comments
 (0)