mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-28 00:56:19 +00:00
Added chat to MessageStory
This commit is contained in:
parent
444ada3b71
commit
7f8c92ace8
@ -798,7 +798,7 @@ class Message(Object, Update):
|
|||||||
game = types.Game._parse(client, message)
|
game = types.Game._parse(client, message)
|
||||||
media_type = enums.MessageMediaType.GAME
|
media_type = enums.MessageMediaType.GAME
|
||||||
elif isinstance(media, raw.types.MessageMediaStory):
|
elif isinstance(media, raw.types.MessageMediaStory):
|
||||||
story = types.MessageStory._parse(media)
|
story = types.MessageStory._parse(client, media, users, chats)
|
||||||
media_type = enums.MessageMediaType.STORY
|
media_type = enums.MessageMediaType.STORY
|
||||||
elif isinstance(media, raw.types.MessageMediaDocument):
|
elif isinstance(media, raw.types.MessageMediaDocument):
|
||||||
doc = media.document
|
doc = media.document
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
# You should have received a copy of the GNU Lesser General Public License
|
# You should have received a copy of the GNU Lesser General Public License
|
||||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from pyrogram import raw
|
import pyrogram
|
||||||
|
from pyrogram import raw, types, utils
|
||||||
from ..object import Object
|
from ..object import Object
|
||||||
|
|
||||||
|
|
||||||
@ -35,22 +36,24 @@ class MessageStory(Object):
|
|||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
chat_id: int,
|
chat: "types.Chat",
|
||||||
story_id: int
|
story_id: int
|
||||||
):
|
):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
self.chat_id = chat_id
|
self.chat = chat
|
||||||
self.story_id = story_id
|
self.story_id = story_id
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse(message_story: "raw.types.MessageMediaStory") -> "MessageStory":
|
def _parse(client: "pyrogram.Client", message_story: "raw.types.MessageMediaStory", users, chats) -> "MessageStory":
|
||||||
|
peer_id = utils.get_raw_peer_id(message_story.peer)
|
||||||
|
|
||||||
if isinstance(message_story.peer, raw.types.PeerChannel):
|
if isinstance(message_story.peer, raw.types.PeerChannel):
|
||||||
chat_id = message_story.peer.channel_id
|
chat = types.Chat._parse_channel_chat(client, chats.get(peer_id, None))
|
||||||
else:
|
else:
|
||||||
chat_id = message_story.peer.user_id
|
chat = types.Chat._parse_user_chat(client, users.get(peer_id, None))
|
||||||
|
|
||||||
return MessageStory(
|
return MessageStory(
|
||||||
chat_id=chat_id,
|
chat=chat,
|
||||||
story_id=message_story.id
|
story_id=message_story.id
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user