mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-18 13:34:54 +00:00
Merge branch 'develop' into asyncio
# Conflicts: # pyrogram/client/client.py # pyrogram/client/dispatcher/dispatcher.py # pyrogram/client/methods/chats/promote_chat_member.py
This commit is contained in:
commit
fcdb71c28c
@ -88,7 +88,7 @@ def generate(source_path, base):
|
|||||||
inner_path = base + "/" + k + "/index" + ".rst"
|
inner_path = base + "/" + k + "/index" + ".rst"
|
||||||
module = "pyrogram.api.{}.{}".format(base, k)
|
module = "pyrogram.api.{}.{}".format(base, k)
|
||||||
else:
|
else:
|
||||||
for i in list(all_entities)[::-1]:
|
for i in sorted(list(all_entities), reverse=True):
|
||||||
if i != base:
|
if i != base:
|
||||||
entities.insert(0, "{0}/index".format(i))
|
entities.insert(0, "{0}/index".format(i))
|
||||||
|
|
||||||
|
@ -67,3 +67,4 @@ 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
|
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
|
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
|
USER_NOT_PARTICIPANT The user is not a member of this chat
|
||||||
|
CHANNEL_PRIVATE The channel/supergroup is not accessible
|
|
@ -1,2 +1,4 @@
|
|||||||
id message
|
id message
|
||||||
CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat
|
CHAT_WRITE_FORBIDDEN You don't have rights to send messages in this chat
|
||||||
|
RIGHT_FORBIDDEN One or more admin rights can't be applied to this kind of chat (channel/supergroup)
|
||||||
|
CHAT_ADMIN_INVITE_REQUIRED You don't have rights to invite other users
|
|
@ -16,7 +16,6 @@
|
|||||||
# 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/>.
|
||||||
|
|
||||||
import logging
|
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
@ -24,23 +23,13 @@ from json import JSONEncoder, dumps
|
|||||||
|
|
||||||
from ..all import objects
|
from ..all import objects
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class Object:
|
class Object:
|
||||||
all = {}
|
all = {}
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def read(b: BytesIO, *args):
|
def read(b: BytesIO, *args):
|
||||||
constructor_id = int.from_bytes(b.read(4), "little")
|
return Object.all[int.from_bytes(b.read(4), "little")].read(b, *args)
|
||||||
|
|
||||||
try:
|
|
||||||
return Object.all[constructor_id].read(b, *args)
|
|
||||||
except KeyError:
|
|
||||||
log.error("Unknown constructor found: {}. Full data: {}".format(
|
|
||||||
hex(constructor_id),
|
|
||||||
b.getvalue().hex())
|
|
||||||
)
|
|
||||||
|
|
||||||
def write(self, *args) -> bytes:
|
def write(self, *args) -> bytes:
|
||||||
pass
|
pass
|
||||||
|
@ -42,7 +42,7 @@ from pyrogram.api.errors import (
|
|||||||
PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty,
|
PhoneNumberUnoccupied, PhoneCodeInvalid, PhoneCodeHashEmpty,
|
||||||
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
PhoneCodeExpired, PhoneCodeEmpty, SessionPasswordNeeded,
|
||||||
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
PasswordHashInvalid, FloodWait, PeerIdInvalid, FirstnameInvalid, PhoneNumberBanned,
|
||||||
VolumeLocNotFound, UserMigrate, FileIdInvalid)
|
VolumeLocNotFound, UserMigrate, FileIdInvalid, ChannelPrivate)
|
||||||
from pyrogram.crypto import AES
|
from pyrogram.crypto import AES
|
||||||
from pyrogram.session import Auth, Session
|
from pyrogram.session import Auth, Session
|
||||||
from .dispatcher import Dispatcher
|
from .dispatcher import Dispatcher
|
||||||
@ -801,6 +801,7 @@ class Client(Methods, BaseClient):
|
|||||||
message = update.message
|
message = update.message
|
||||||
|
|
||||||
if not isinstance(message, types.MessageEmpty):
|
if not isinstance(message, types.MessageEmpty):
|
||||||
|
try:
|
||||||
diff = await self.send(
|
diff = await self.send(
|
||||||
functions.updates.GetChannelDifference(
|
functions.updates.GetChannelDifference(
|
||||||
channel=await self.resolve_peer(int("-100" + str(channel_id))),
|
channel=await self.resolve_peer(int("-100" + str(channel_id))),
|
||||||
@ -814,7 +815,9 @@ class Client(Methods, BaseClient):
|
|||||||
limit=pts
|
limit=pts
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
except ChannelPrivate:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
if not isinstance(diff, types.updates.ChannelDifferenceEmpty):
|
if not isinstance(diff, types.updates.ChannelDifferenceEmpty):
|
||||||
updates.users += diff.users
|
updates.users += diff.users
|
||||||
updates.chats += diff.chats
|
updates.chats += diff.chats
|
||||||
|
@ -90,6 +90,7 @@ class Dispatcher:
|
|||||||
tasks = []
|
tasks = []
|
||||||
|
|
||||||
for group in self.groups.values():
|
for group in self.groups.values():
|
||||||
|
try:
|
||||||
for handler in group:
|
for handler in group:
|
||||||
if is_raw:
|
if is_raw:
|
||||||
if not isinstance(handler, RawUpdateHandler):
|
if not isinstance(handler, RawUpdateHandler):
|
||||||
@ -127,6 +128,8 @@ class Dispatcher:
|
|||||||
|
|
||||||
tasks.append(handler.callback(*args))
|
tasks.append(handler.callback(*args))
|
||||||
break
|
break
|
||||||
|
except Exception as e:
|
||||||
|
log.error(e, exc_info=True)
|
||||||
|
|
||||||
await asyncio.gather(*tasks)
|
await asyncio.gather(*tasks)
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ class PromoteChatMember(BaseClient):
|
|||||||
chat_id: int or str,
|
chat_id: int or str,
|
||||||
user_id: int or str,
|
user_id: int or str,
|
||||||
can_change_info: bool = True,
|
can_change_info: bool = True,
|
||||||
can_post_messages: bool = True,
|
can_post_messages: bool = False,
|
||||||
can_edit_messages: bool = True,
|
can_edit_messages: bool = False,
|
||||||
can_delete_messages: bool = True,
|
can_delete_messages: bool = True,
|
||||||
can_invite_users: bool = True,
|
can_invite_users: bool = True,
|
||||||
can_restrict_members: bool = True,
|
can_restrict_members: bool = True,
|
||||||
can_pin_messages: bool = True,
|
can_pin_messages: bool = False,
|
||||||
can_promote_members: bool = False):
|
can_promote_members: bool = False):
|
||||||
"""Use this method to promote or demote a user in a supergroup or a channel.
|
"""Use this method to promote or demote a user in a supergroup or a channel.
|
||||||
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
You must be an administrator in the chat for this to work and must have the appropriate admin rights.
|
||||||
|
Loading…
Reference in New Issue
Block a user