Add new Messages object and make get_history return it
This commit is contained in:
parent
f7aca803b1
commit
ef93fee7aa
@ -495,6 +495,7 @@ def start():
|
||||
f.write("\n 0xb0700016: \"pyrogram.client.types.ChatMember\",")
|
||||
f.write("\n 0xb0700017: \"pyrogram.client.types.Sticker\",")
|
||||
f.write("\n 0xb0700025: \"pyrogram.client.types.GIF\",")
|
||||
f.write("\n 0xb0700026: \"pyrogram.client.types.Messages\",")
|
||||
|
||||
f.write("\n 0xb0700018: \"pyrogram.client.types.reply_markup.ForceReply\",")
|
||||
f.write("\n 0xb0700019: \"pyrogram.client.types.reply_markup.InlineKeyboardButton\",")
|
||||
|
@ -30,7 +30,7 @@ from .client.types import (
|
||||
Audio, Chat, ChatMember, ChatPhoto, Contact, Document, InputMediaPhoto,
|
||||
InputMediaVideo, InputPhoneContact, Location, Message, MessageEntity,
|
||||
PhotoSize, Sticker, Update, User, UserProfilePhotos, Venue, GIF, Video,
|
||||
VideoNote, Voice, CallbackQuery
|
||||
VideoNote, Voice, CallbackQuery, Messages
|
||||
)
|
||||
from .client.types.reply_markup import (
|
||||
ForceReply, InlineKeyboardButton, InlineKeyboardMarkup,
|
||||
|
@ -253,7 +253,7 @@ def parse_messages(
|
||||
users: dict,
|
||||
chats: dict,
|
||||
replies: int = 1
|
||||
) -> pyrogram_types.Message:
|
||||
) -> pyrogram_types.Message or list:
|
||||
is_list = isinstance(messages, list)
|
||||
messages = messages if is_list else [messages]
|
||||
parsed_messages = []
|
||||
|
@ -16,6 +16,7 @@
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import pyrogram
|
||||
from pyrogram.api import functions
|
||||
from ...ext import BaseClient, utils
|
||||
|
||||
@ -51,6 +52,12 @@ class GetHistory(BaseClient):
|
||||
|
||||
offset_date (``int``, *optional*):
|
||||
Pass a date in Unix time as offset to retrieve only older messages starting from that date.
|
||||
|
||||
Returns:
|
||||
On success, a :obj:`Messages <pyrogram.Messages>` object is returned.
|
||||
|
||||
Raises:
|
||||
:class:`Error <pyrogram.Error>`
|
||||
"""
|
||||
|
||||
r = self.send(
|
||||
@ -98,4 +105,7 @@ class GetHistory(BaseClient):
|
||||
if r.messages[i].reply_to_msg_id:
|
||||
messages[i].reply_to_message = reply_to_messages[r.messages[i].reply_to_msg_id]
|
||||
|
||||
return messages
|
||||
return pyrogram.Messages(
|
||||
total_count=r.count,
|
||||
messages=messages
|
||||
)
|
||||
|
@ -43,3 +43,4 @@ from .venue import Venue
|
||||
from .video import Video
|
||||
from .video_note import VideoNote
|
||||
from .voice import Voice
|
||||
from .messages import Messages
|
||||
|
40
pyrogram/client/types/messages.py
Normal file
40
pyrogram/client/types/messages.py
Normal file
@ -0,0 +1,40 @@
|
||||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from pyrogram.api.core import Object
|
||||
|
||||
|
||||
class Messages(Object):
|
||||
"""This object represent a chat's messages.
|
||||
|
||||
Attributes:
|
||||
ID: ``0xb0700026``
|
||||
|
||||
Args:
|
||||
total_count (``int``):
|
||||
Total number of messages the target chat has.
|
||||
|
||||
messages (List of :obj:`Message <pyrogram.Message>`):
|
||||
Requested messages.
|
||||
"""
|
||||
|
||||
ID = 0xb0700026
|
||||
|
||||
def __init__(self, total_count: int, messages: list):
|
||||
self.total_count = total_count # int
|
||||
self.messages = messages # Vector<Vector<PhotoSize>>
|
Loading…
Reference in New Issue
Block a user