2
0
mirror of https://github.com/pyrogram/pyrogram synced 2025-08-29 13:27:47 +00:00

Merge branch 'develop'

This commit is contained in:
Dan 2018-11-04 18:00:19 +01:00
commit 7d1e1c9fda
5 changed files with 25 additions and 38 deletions

View File

@ -68,3 +68,4 @@ USER_CHANNELS_TOO_MUCH The user is already in too many channels or supergroups
API_ID_PUBLISHED_FLOOD You are using an API key that is limited on the server side
USER_NOT_PARTICIPANT The user is not a member of this chat
CHANNEL_PRIVATE The channel/supergroup is not accessible
MESSAGE_IDS_EMPTY The requested message doesn't exist
1 id message
68 API_ID_PUBLISHED_FLOOD You are using an API key that is limited on the server side
69 USER_NOT_PARTICIPANT The user is not a member of this chat
70 CHANNEL_PRIVATE The channel/supergroup is not accessible
71 MESSAGE_IDS_EMPTY The requested message doesn't exist

View File

@ -82,7 +82,7 @@ If no error shows up you are good to go.
>>> import pyrogram
>>> pyrogram.__version__
'0.9.0'
'0.9.1'
.. _TgCrypto: https://docs.pyrogram.ml/resources/TgCrypto
.. _develop: http://github.com/pyrogram/pyrogram

View File

@ -23,7 +23,7 @@ __copyright__ = "Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance
"e" if sys.getfilesystemencoding() != "utf-8" else "\xe8"
)
__license__ = "GNU Lesser General Public License v3 or later (LGPLv3+)"
__version__ = "0.9.0"
__version__ = "0.9.1"
from .api.errors import Error
from .client.types import (

View File

@ -17,15 +17,13 @@
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import logging
import time
from base64 import b64decode, b64encode
from struct import pack
from weakref import proxy
from pyrogram.api.errors import FloodWait
from pyrogram.client import types as pyrogram_types
from ...api import types, functions
from ...api.errors import StickersetInvalid
from ...api.errors import StickersetInvalid, MessageIdsEmpty
log = logging.getLogger(__name__)
@ -215,7 +213,7 @@ def parse_channel_chat(channel: types.Channel) -> pyrogram_types.Chat:
title=channel.title,
username=getattr(channel, "username", None),
photo=parse_chat_photo(getattr(channel, "photo", None)),
restriction_reason=getattr(channel, "restriction_reason")
restriction_reason=getattr(channel, "restriction_reason", None)
)
@ -635,19 +633,14 @@ def parse_messages(
m.caption.init(m._client, m.caption_entities or [])
if message.reply_to_msg_id and replies:
while True:
try:
m.reply_to_message = client.get_messages(
m.chat.id,
reply_to_message_ids=message.id,
replies=replies - 1
)
except FloodWait as e:
log.warning("get_messages flood: waiting {} seconds".format(e.x))
time.sleep(e.x)
continue
else:
break
except MessageIdsEmpty:
m.reply_to_message = None
elif isinstance(message, types.MessageService):
action = message.action
@ -748,19 +741,11 @@ def parse_messages(
)
if isinstance(action, types.MessageActionPinMessage):
while True:
try:
m.pinned_message = client.get_messages(
m.chat.id,
reply_to_message_ids=message.id,
replies=0
)
except FloodWait as e:
log.warning("get_messages flood: waiting {} seconds".format(e.x))
time.sleep(e.x)
continue
else:
break
else:
m = pyrogram_types.Message(message_id=message.id, client=proxy(client))
@ -973,6 +958,7 @@ def parse_chat_members(members: types.channels.ChannelParticipants or types.mess
parsed_members = []
if isinstance(members, types.channels.ChannelParticipants):
count = members.count
members = members.participants
for member in members:
@ -1031,7 +1017,7 @@ def parse_chat_members(members: types.channels.ChannelParticipants or types.mess
parsed_members.append(chat_member)
return pyrogram_types.ChatMembers(
total_count=members.count,
total_count=count,
chat_members=parsed_members
)
else:

View File

@ -31,7 +31,7 @@ class InlineKeyboardButton(Object):
text (``str``):
Label text on the button.
callback_data (``str``, *optional*):
callback_data (``bytes``, *optional*):
Data to be sent in a callback query to the bot when button is pressed, 1-64 bytes.
url (``str``, *optional*):
@ -59,7 +59,7 @@ class InlineKeyboardButton(Object):
def __init__(
self,
text: str,
callback_data: str = None,
callback_data: bytes = None,
url: str = None,
switch_inline_query: str = None,
switch_inline_query_current_chat: str = None,
@ -85,7 +85,7 @@ class InlineKeyboardButton(Object):
if isinstance(b, KeyboardButtonCallback):
return InlineKeyboardButton(
text=b.text,
callback_data=b.data.decode()
callback_data=b.data
)
if isinstance(b, KeyboardButtonSwitchInline):
@ -102,7 +102,7 @@ class InlineKeyboardButton(Object):
def write(self):
if self.callback_data:
return KeyboardButtonCallback(self.text, self.callback_data.encode())
return KeyboardButtonCallback(self.text, self.callback_data)
if self.url:
return KeyboardButtonUrl(self.text, self.url)