Skip to content

Commit 96bdbdd

Browse files
committed
Improve documentation of some of the Service Messages
1 parent a00c2a0 commit 96bdbdd

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

pyrogram/types/messages_and_media/message.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ class Message(Object, Update):
234234
left_chat_member (:obj:`~pyrogram.types.User`, *optional*):
235235
A member was removed from the group, information about them (this member may be the bot itself).
236236
237+
old_chat_title (``str``, *optional*):
238+
The supergroup has been migrated from a group with the specified title.
239+
237240
new_chat_title (``str``, *optional*):
238241
A chat title was changed to this value.
239242
@@ -507,6 +510,7 @@ def __init__(
507510
location: "types.Location" = None,
508511
new_chat_members: list["types.User"] = None,
509512
left_chat_member: "types.User" = None,
513+
old_chat_title: str = None,
510514
new_chat_title: str = None,
511515
new_chat_photo: "types.Photo" = None,
512516
delete_chat_photo: bool = None,
@@ -623,6 +627,7 @@ def __init__(
623627
self.dice = dice
624628
self.new_chat_members = new_chat_members
625629
self.left_chat_member = left_chat_member
630+
self.old_chat_title = old_chat_title
626631
self.new_chat_title = new_chat_title
627632
self.new_chat_photo = new_chat_photo
628633
self.delete_chat_photo = delete_chat_photo
@@ -757,6 +762,7 @@ async def _parse(
757762

758763
new_chat_members = None
759764
left_chat_member = None
765+
old_chat_title = None
760766
new_chat_title = None
761767
delete_chat_photo = None
762768
migrate_to_chat_id = None
@@ -812,6 +818,7 @@ async def _parse(
812818
new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])]
813819
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
814820
chat_join_type = enums.ChatJoinType.BY_LINK
821+
from_user = types.User._parse(client, users.get(action.inviter_id, None))
815822
elif isinstance(action, raw.types.MessageActionChatJoinedByRequest):
816823
new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])]
817824
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
@@ -829,12 +836,16 @@ async def _parse(
829836
migrate_to_chat_id = action.channel_id
830837
service_type = enums.MessageServiceType.MIGRATE_TO_CHAT_ID
831838
elif isinstance(action, raw.types.MessageActionChannelMigrateFrom):
839+
old_chat_title = action.title
832840
migrate_from_chat_id = action.chat_id
833841
service_type = enums.MessageServiceType.MIGRATE_FROM_CHAT_ID
834842
elif isinstance(action, raw.types.MessageActionChatCreate):
843+
new_chat_members = [types.User._parse(client, users[user]) for user in action.users]
844+
new_chat_title = action.title
835845
group_chat_created = True
836846
service_type = enums.MessageServiceType.GROUP_CHAT_CREATED
837847
elif isinstance(action, raw.types.MessageActionChannelCreate):
848+
new_chat_title = action.title
838849
if chat.type == enums.ChatType.SUPERGROUP:
839850
supergroup_chat_created = True
840851
service_type = enums.MessageServiceType.SUPERGROUP_CHAT_CREATED
@@ -857,7 +868,7 @@ async def _parse(
857868
elif isinstance(action, raw.types.MessageActionInviteToGroupCall):
858869
video_chat_participants_invited = types.VideoChatParticipantsInvited._parse(client, action, users)
859870
service_type = enums.MessageServiceType.VIDEO_CHAT_PARTICIPANTS_INVITED
860-
elif isinstance(action, raw.types.MessageActionWebViewDataSentMe):
871+
elif isinstance(action, (raw.types.MessageActionWebViewDataSentMe, raw.types.MessageActionWebViewDataSent)):
861872
web_app_data = types.WebAppData._parse(action)
862873
service_type = enums.MessageServiceType.WEB_APP_DATA
863874
elif isinstance(action, raw.types.MessageActionGiveawayLaunch):
@@ -1090,6 +1101,7 @@ async def _parse(
10901101
service=service_type,
10911102
new_chat_members=new_chat_members,
10921103
left_chat_member=left_chat_member,
1104+
old_chat_title=old_chat_title,
10931105
new_chat_title=new_chat_title,
10941106
new_chat_photo=new_chat_photo,
10951107
delete_chat_photo=delete_chat_photo,

pyrogram/types/messages_and_media/web_app_data.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ class WebAppData(Object):
2424
"""Contains data sent from a `Web App <https://core.telegram.org/bots/webapps>`_ to the bot.
2525
2626
Parameters:
27-
data (``str``):
28-
The data.
27+
data (``str``, *optional*):
28+
The data. Be aware that a bad client can send arbitrary data in this field.
2929
3030
button_text (``str``):
31-
Text of the *web_app* keyboard button, from which the Web App was opened.
31+
Text of the *web_app* keyboard button from which the Web App was opened. Be aware that a bad client can send arbitrary data in this field.
3232
3333
"""
3434

@@ -46,6 +46,6 @@ def __init__(
4646
@staticmethod
4747
def _parse(action: "raw.types.MessageActionWebViewDataSentMe"):
4848
return WebAppData(
49-
data=action.data,
49+
data=getattr(action, "data", None),
5050
button_text=action.text
5151
)

0 commit comments

Comments
 (0)