Skip to content

Commit bf17dc4

Browse files
alissonlaufferwulan17SpEcHiDenull-nick
authored
feat!: update API schema to Layer 166 and add topics support
* feat: add support for Forum Topic and update to layer 160 * chore: update API Scheme to Layer 165 * chore: update API schema to Layer 166 * refactor: fix ruff issues * cleanup: use utils.get_reply_head_fm where applicable * fix: remove duplicated reply_to caused by merge * fix: some misc fixes * chore: tidy up license headers * fix: expose types in hydrogram.types * fix: expose errors in hydrogram.errors --------- Co-authored-by: wulan17 <wulan17@nusantararom.org> Co-authored-by: shriMADhav U k <hetzner@shrimadhavuk.me> Co-authored-by: Nick <64551534+null-nick@users.noreply.github.com>
1 parent 8ba9582 commit bf17dc4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1933
-110
lines changed

NOTICE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Hydrogram - Telegram MTProto API Client Library for Python
2-
Copyright (C) 2017-2023 Dan <https://github.com/delivrance>
32
Copyright (C) 2023-present Amano LLC <https://amanoteam.com>
43

54
This file is part of Hydrogram.

compiler/api/source/main_api.tl

Lines changed: 190 additions & 63 deletions
Large diffs are not rendered by default.

compiler/docs/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Hydrogram - Telegram MTProto API Client Library for Python
2-
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
2+
# Copyright (C) 2023-present Amano LLC <https://amanoteam.com>
33
#
44
# This file is part of Hydrogram.
55
#

compiler/docs/compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Hydrogram - Telegram MTProto API Client Library for Python
2-
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
2+
# Copyright (C) 2023-present Amano LLC <https://amanoteam.com>
33
#
44
# This file is part of Hydrogram.
55
#

compiler/errors/source/400_BAD_REQUEST.tsv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ CHANNEL_TOO_LARGE The channel is too large
5555
CHAT_ABOUT_NOT_MODIFIED The chat about text was not modified because you tried to edit it using the same content
5656
CHAT_ABOUT_TOO_LONG The chat about text is too long
5757
CHAT_ADMIN_REQUIRED The method requires chat admin privileges
58+
CHAT_DISCUSSION_UNALLOWED The chat discussion is not allowed
5859
CHAT_FORWARDS_RESTRICTED The chat restricts forwarding content
5960
CHAT_ID_EMPTY The provided chat id is empty
6061
CHAT_ID_INVALID The chat id being used is invalid or not known yet. Make sure you see the chat before interacting with it
@@ -168,9 +169,12 @@ MAX_QTS_INVALID The provided QTS is invalid
168169
MD5_CHECKSUM_INVALID The file's checksum did not match the md5_checksum parameter
169170
MEDIA_CAPTION_TOO_LONG The media caption is too long
170171
MEDIA_EMPTY The media you tried to send is invalid
172+
MEDIA_FILE_INVALID The media file is invalid
171173
MEDIA_INVALID The media is invalid
172174
MEDIA_NEW_INVALID The new media to edit the message with is invalid
173175
MEDIA_PREV_INVALID The previous media cannot be edited with anything else
176+
MEDIA_TTL_INVALID The media ttl is invalid
177+
MEDIA_VIDEO_STORY_MISSING The media does not have a photo or a video
174178
MEGAGROUP_ID_INVALID The supergroup is invalid
175179
MEGAGROUP_PREHISTORY_HIDDEN The action failed because the supergroup has the pre-history hidden
176180
MEGAGROUP_REQUIRED The request can only be used with a supergroup
@@ -183,6 +187,7 @@ MESSAGE_POLL_CLOSED You can't interact with a closed poll
183187
MESSAGE_TOO_LONG The message text is too long
184188
METHOD_INVALID The API method is invalid and cannot be used
185189
MSG_ID_INVALID The message ID used in the peer was invalid
190+
MSG_VOICE_MISSING The message does not contain a voice message
186191
MSG_WAIT_FAILED A waiting call returned an error
187192
MULTI_MEDIA_TOO_LONG The album/media group contains too many items
188193
NEW_SALT_INVALID The new salt is invalid
@@ -240,6 +245,7 @@ POLL_OPTION_INVALID A poll option used invalid data (the data may be too long)
240245
POLL_QUESTION_INVALID The poll question is invalid
241246
POLL_UNSUPPORTED This layer does not support polls in the invoked method
242247
POLL_VOTE_REQUIRED Cast a vote in the poll before calling this method
248+
PREMIUM_ACCOUNT_REQUIRED The method requires a premium user account
243249
PRIVACY_KEY_INVALID The privacy key is invalid
244250
PRIVACY_TOO_LONG Your privacy exception list has exceeded the maximum capacity
245251
PRIVACY_VALUE_INVALID The privacy value is invalid
@@ -302,6 +308,7 @@ STICKER_PNG_NOPNG Stickers must be png files but the provided image was not a pn
302308
STICKER_TGS_NOTGS A tgs sticker file was expected, but something else was provided
303309
STICKER_THUMB_PNG_NOPNG A png sticker thumbnail file was expected, but something else was provided
304310
STICKER_VIDEO_NOWEBM A webm video file was expected, but something else was provided
311+
STORIES_TOO_MUCH Too many stories in the current account
305312
TAKEOUT_INVALID The takeout id is invalid
306313
TAKEOUT_REQUIRED The method must be invoked inside a takeout session
307314
TEMP_AUTH_KEY_EMPTY The temporary auth key provided is empty
@@ -312,8 +319,12 @@ THEME_MIME_INVALID You cannot create this theme because the mime-type is invalid
312319
TMP_PASSWORD_DISABLED The temporary password is disabled
313320
TMP_PASSWORD_INVALID The temporary password is invalid
314321
TOKEN_INVALID The provided token is invalid
322+
TOPIC_CLOSED The topic was closed
323+
TOPIC_DELETED The topic was deleted
324+
TRANSCRIPTION_FAILED Telegram is having internal problems. Please try again later to transcribe the audio.
315325
TTL_DAYS_INVALID The provided TTL days is invalid
316326
TTL_MEDIA_INVALID The media does not support self-destruction
327+
TTL_PERIOD_INVALID The provided TTL period is invalid
317328
TYPES_EMPTY The types parameter is empty
318329
TYPE_CONSTRUCTOR_INVALID The type constructor is invalid
319330
UNTIL_DATE_INVALID That date parameter is invalid
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
id message
22
ApiCallError Telegram is having internal problems. Please try again later.
33
Timeout Telegram is having internal problems. Please try again later.
4+
Timedout Telegram is having internal problems. Please try again later.

hydrogram/enums/chat_event_action.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,14 @@ class ChatEventAction(AutoName):
124124
MESSAGE_UNPINNED = auto()
125125
"a message has been unpinned (see ``unpinned_message``)"
126126

127+
CREATED_FORUM_TOPIC = auto()
128+
"a new forum topic has been created (see `created_forum_topic`)"
129+
130+
EDITED_FORUM_TOPIC = auto()
131+
"a forum topic has been edited (see `old_forum_topic` and `new_forum_topic`)"
132+
133+
DELETED_FORUM_TOPIC = auto()
134+
"a forum topic has been deleted (see `deleted_forum_topic`)"
135+
127136
UNKNOWN = auto()
128137
"Unknown chat event action"

hydrogram/enums/message_service_type.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,24 @@ class MessageServiceType(AutoName):
5858
GAME_HIGH_SCORE = auto()
5959
"Game high score"
6060

61+
FORUM_TOPIC_CREATED = auto()
62+
"a new forum topic created in the chat"
63+
64+
FORUM_TOPIC_CLOSED = auto()
65+
"a new forum topic closed in the chat"
66+
67+
FORUM_TOPIC_REOPENED = auto()
68+
"a new forum topic reopened in the chat"
69+
70+
FORUM_TOPIC_EDITED = auto()
71+
"a new forum topic renamed in the chat"
72+
73+
GENERAL_TOPIC_HIDDEN = auto()
74+
"a forum general topic hidden in the chat"
75+
76+
GENERAL_TOPIC_UNHIDDEN = auto()
77+
"a forum general topic unhidden in the chat"
78+
6179
VIDEO_CHAT_STARTED = auto()
6280
"Video chat started"
6381

hydrogram/errors/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
ChatAboutTooLong,
8989
ChatAdminInviteRequired,
9090
ChatAdminRequired,
91+
ChatDiscussionUnallowed,
9192
ChatForbidden,
9293
ChatForwardsRestricted,
9394
ChatIdEmpty,
@@ -229,9 +230,12 @@
229230
Md5ChecksumInvalid,
230231
MediaCaptionTooLong,
231232
MediaEmpty,
233+
MediaFileInvalid,
232234
MediaInvalid,
233235
MediaNewInvalid,
234236
MediaPrevInvalid,
237+
MediaTtlInvalid,
238+
MediaVideoStoryMissing,
235239
MegagroupIdInvalid,
236240
MegagroupPrehistoryHidden,
237241
MegagroupRequired,
@@ -252,6 +256,7 @@
252256
MsgidDecreaseRetry,
253257
MsgIdInvalid,
254258
MsgRangeUnsync,
259+
MsgVoiceMissing,
255260
MsgWaitFailed,
256261
MtSendQueueTooLong,
257262
MultiMediaTooLong,
@@ -404,6 +409,7 @@
404409
StickerVideoNowebm,
405410
StorageCheckFailed,
406411
StoreInvalidScalarType,
412+
StoriesTooMuch,
407413
TakeoutInitDelay,
408414
TakeoutInvalid,
409415
TakeoutRequired,
@@ -416,8 +422,12 @@
416422
TmpPasswordDisabled,
417423
TmpPasswordInvalid,
418424
TokenInvalid,
425+
TopicClosed,
426+
TopicDeleted,
427+
TranscriptionFailed,
419428
TtlDaysInvalid,
420429
TtlMediaInvalid,
430+
TtlPeriodInvalid,
421431
TwoFaConfirmWait,
422432
TypeConstructorInvalid,
423433
TypesEmpty,
@@ -600,6 +610,7 @@ def __init__(self, msg: Optional[str] = None):
600610
"ChatAboutTooLong",
601611
"ChatAdminInviteRequired",
602612
"ChatAdminRequired",
613+
"ChatDiscussionUnallowed",
603614
"ChatForbidden",
604615
"ChatForwardsRestricted",
605616
"ChatIdEmpty",
@@ -741,9 +752,12 @@ def __init__(self, msg: Optional[str] = None):
741752
"Md5ChecksumInvalid",
742753
"MediaCaptionTooLong",
743754
"MediaEmpty",
755+
"MediaFileInvalid",
744756
"MediaInvalid",
745757
"MediaNewInvalid",
746758
"MediaPrevInvalid",
759+
"MediaTtlInvalid",
760+
"MediaVideoStoryMissing",
747761
"MegagroupIdInvalid",
748762
"MegagroupPrehistoryHidden",
749763
"MegagroupRequired",
@@ -763,6 +777,7 @@ def __init__(self, msg: Optional[str] = None):
763777
"MethodInvalid",
764778
"MsgIdInvalid",
765779
"MsgRangeUnsync",
780+
"MsgVoiceMissing",
766781
"MsgWaitFailed",
767782
"MsgidDecreaseRetry",
768783
"MtSendQueueTooLong",
@@ -916,6 +931,7 @@ def __init__(self, msg: Optional[str] = None):
916931
"StickersetOwnerAnonymous",
917932
"StorageCheckFailed",
918933
"StoreInvalidScalarType",
934+
"StoriesTooMuch",
919935
"TakeoutInitDelay",
920936
"TakeoutInvalid",
921937
"TakeoutRequired",
@@ -928,8 +944,12 @@ def __init__(self, msg: Optional[str] = None):
928944
"TmpPasswordDisabled",
929945
"TmpPasswordInvalid",
930946
"TokenInvalid",
947+
"TopicClosed",
948+
"TopicDeleted",
949+
"TranscriptionFailed",
931950
"TtlDaysInvalid",
932951
"TtlMediaInvalid",
952+
"TtlPeriodInvalid",
933953
"TwoFaConfirmWait",
934954
"TypeConstructorInvalid",
935955
"TypesEmpty",

hydrogram/methods/bots/send_game.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,15 @@
2020
from typing import Optional, Union
2121

2222
import hydrogram
23-
from hydrogram import raw, types
23+
from hydrogram import raw, types, utils
2424

2525

2626
class SendGame:
2727
async def send_game(
2828
self: "hydrogram.Client",
2929
chat_id: Union[int, str],
3030
game_short_name: str,
31+
message_thread_id: Optional[int] = None,
3132
disable_notification: Optional[bool] = None,
3233
reply_to_message_id: Optional[int] = None,
3334
protect_content: Optional[bool] = None,
@@ -51,6 +52,10 @@ async def send_game(
5152
game_short_name (``str``):
5253
Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
5354
55+
message_thread_id (``int``, *optional*):
56+
Unique identifier of a message thread to which the message belongs.
57+
for supergroups only
58+
5459
disable_notification (``bool``, *optional*):
5560
Sends the message silently.
5661
Users will receive a notification with no sound.
@@ -73,6 +78,8 @@ async def send_game(
7378
7479
await app.send_game(chat_id, "gamename")
7580
"""
81+
reply_to = utils.get_reply_head_fm(message_thread_id, reply_to_message_id)
82+
7683
r = await self.invoke(
7784
raw.functions.messages.SendMedia(
7885
peer=await self.resolve_peer(chat_id),
@@ -83,7 +90,7 @@ async def send_game(
8390
),
8491
message="",
8592
silent=disable_notification or None,
86-
reply_to_msg_id=reply_to_message_id,
93+
reply_to=reply_to,
8794
random_id=self.rnd_id(),
8895
noforwards=protect_content,
8996
reply_markup=await reply_markup.write(self) if reply_markup else None,

0 commit comments

Comments
 (0)