mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 05:30:15 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/__init__.py # pyrogram/client/ext/utils.py
This commit is contained in:
commit
a9c4c72e5f
@ -67,4 +67,5 @@ USER_NOT_MUTUAL_CONTACT The user is not a mutual contact
|
||||
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
|
||||
CHANNEL_PRIVATE The channel/supergroup is not accessible
|
||||
MESSAGE_IDS_EMPTY The requested message doesn't exist
|
|
@ -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
|
||||
|
@ -31,7 +31,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.async1"
|
||||
__version__ = "0.9.1.async1"
|
||||
|
||||
from .api.errors import Error
|
||||
from .client.types import (
|
||||
|
@ -19,16 +19,14 @@
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
from base64 import b64decode, b64encode
|
||||
from concurrent.futures.thread import ThreadPoolExecutor
|
||||
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__)
|
||||
|
||||
@ -227,7 +225,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)
|
||||
)
|
||||
|
||||
|
||||
@ -647,19 +645,14 @@ async 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 = await 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
|
||||
try:
|
||||
m.reply_to_message = await client.get_messages(
|
||||
m.chat.id,
|
||||
reply_to_message_ids=message.id,
|
||||
replies=replies - 1
|
||||
)
|
||||
except MessageIdsEmpty:
|
||||
m.reply_to_message = None
|
||||
elif isinstance(message, types.MessageService):
|
||||
action = message.action
|
||||
|
||||
@ -760,19 +753,11 @@ async def parse_messages(
|
||||
)
|
||||
|
||||
if isinstance(action, types.MessageActionPinMessage):
|
||||
while True:
|
||||
try:
|
||||
m.pinned_message = await 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
|
||||
m.pinned_message = await client.get_messages(
|
||||
m.chat.id,
|
||||
reply_to_message_ids=message.id,
|
||||
replies=0
|
||||
)
|
||||
else:
|
||||
m = pyrogram_types.Message(message_id=message.id, client=proxy(client))
|
||||
|
||||
@ -985,6 +970,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:
|
||||
@ -1043,7 +1029,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:
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user