mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-30 17:59:55 +03:00
commit
This commit is contained in:
parent
6484440205
commit
3436e4e57d
|
@ -1185,10 +1185,12 @@ class ChatMethods:
|
|||
async def get_permissions(
|
||||
self: 'TelegramClient',
|
||||
entity: 'hints.EntityLike',
|
||||
user: 'hints.EntityLike'
|
||||
user: 'hints.EntityLike' = None
|
||||
) -> 'typing.Optional[custom.ParticipantPermissions]':
|
||||
"""
|
||||
Fetches the permissions of a user in a specific chat or channel.
|
||||
Fetches the permissions of a user in a specific chat or channel or
|
||||
get Default Restricted Rights of Chat or Channel.
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -1199,7 +1201,7 @@ class ChatMethods:
|
|||
entity (`entity`):
|
||||
The channel or chat the user is participant of.
|
||||
|
||||
user (`entity`):
|
||||
user (`entity`, optional):
|
||||
Target user.
|
||||
|
||||
Returns
|
||||
|
@ -1213,8 +1215,19 @@ class ChatMethods:
|
|||
permissions = await client.get_permissions(chat, user)
|
||||
if permissions.is_admin:
|
||||
# do something
|
||||
|
||||
# Get Banned Permissions of Chat
|
||||
await client.get_permissions(chat)
|
||||
"""
|
||||
entity = await self.get_input_entity(entity)
|
||||
if not user:
|
||||
if isinstance(entity, types.Channel):
|
||||
FullChat = await self(functions.channels.GetFullChannelRequest(entity))
|
||||
elif isinstance(entity, types.Chat):
|
||||
FullChat = await self(functions.messages.GetFullChatRequest(entity))
|
||||
else:
|
||||
return
|
||||
return FullChat.chats[0].default_banned_rights
|
||||
user = await self.get_input_entity(user)
|
||||
if helpers._entity_type(user) != helpers._EntityType.USER:
|
||||
raise ValueError('You must pass a user entity')
|
||||
|
@ -1320,7 +1333,9 @@ class ChatMethods:
|
|||
method: str,
|
||||
entity: 'hints.EntityLike',
|
||||
schedule: 'hints.DateLike' = None,
|
||||
title: str = None
|
||||
title: str = None,
|
||||
reset_invite_hash: bool = None,
|
||||
join_muted: bool = None
|
||||
):
|
||||
"""
|
||||
Stuff to do with Group Calls, Possible for Administrator and
|
||||
|
@ -1332,15 +1347,30 @@ class ChatMethods:
|
|||
`edit_title` will work. Check Examples to know more Clearly.
|
||||
|
||||
entity (`int` | `str`):
|
||||
Username/ID of Channel, where to Modify Group Call.
|
||||
Username/ID of Channel or Chat, where to Modify Group Call.
|
||||
|
||||
schedule (`hints.Datelike`, optional):
|
||||
schedule (`hints.Datelike`, `optional`):
|
||||
Used to Schedule the GroupCall.
|
||||
|
||||
title (str, optional):
|
||||
title (`str`, `optional`):
|
||||
Edits the Group call Title. It should be used with
|
||||
`edit_title` as method parameter.
|
||||
|
||||
reset_invite_hash (`bool`, `optional`):
|
||||
Reset the Invite Hash of Group Call of Specific Channel or
|
||||
Chat.
|
||||
|
||||
join_muted (`bool`, `optional`):
|
||||
Whether the New Group Call Participant should be Muted or
|
||||
Not.
|
||||
|
||||
Method Parameter :
|
||||
- `create` : `Create a Group Call or Schedule It.`
|
||||
- `discard` : `Stop a Group Call.`
|
||||
- `edit_title` : `Edit title of Group Call.`
|
||||
- `edit_perms` : `Edit Permissions of Group Call.`
|
||||
- `start_schedule` : `Start a Group Call which was Scheduled.`
|
||||
|
||||
Returns
|
||||
The resulting :tl:`Updates` object.
|
||||
|
||||
|
@ -1371,6 +1401,15 @@ class ChatMethods:
|
|||
|
||||
# Stopping/Closing a Group Call
|
||||
await client.modify_groupcall("discard", -100123456789)
|
||||
|
||||
# Force Start Scheduled Group Call
|
||||
await client.modify_groupcall("start_schedule", chat)
|
||||
|
||||
# Toggle Group Call Setting
|
||||
await client.modify_groupcall(
|
||||
"edit_perms",
|
||||
reset_invite_hash=True,
|
||||
join_muted=True) # Mute New Group call Participants
|
||||
"""
|
||||
if not method:
|
||||
return self._log[__name__].info("Method Cant be None.")
|
||||
|
@ -1382,16 +1421,28 @@ class ChatMethods:
|
|||
schedule=schedule)
|
||||
).updates[0]
|
||||
try:
|
||||
Call = await self(functions.messages.GetFullChatRequest(entity))
|
||||
Call = await self(
|
||||
functions.messages.GetFullChatRequest(entity))
|
||||
except errors.rpcerrorlist.ChatIdInvalidError:
|
||||
Call = await self(functions. channels.GetFullChannelRequest(entity))
|
||||
Call = await self(
|
||||
functions.channels.GetFullChannelRequest(entity))
|
||||
if method == "edit_title":
|
||||
return (await self(functions.phone.EditGroupCallTitleRequest(
|
||||
Call, title=title if title else ""))).updates
|
||||
elif method == "edit_perms":
|
||||
reqs = await self(
|
||||
functions.phone.ToggleGroupCallSettingsRequest(
|
||||
reset_invite_hash=reset_invite_hash,
|
||||
call=Call,
|
||||
join_muted=join_muted))
|
||||
return reqs.updates
|
||||
elif method == "discard":
|
||||
return (await self(functions.phone.DiscardGroupCallRequest(Call))).updates
|
||||
return (await self(
|
||||
functions.phone.DiscardGroupCallRequest(Call))).updates
|
||||
elif method == "start_schedule":
|
||||
return (await self(functions.phone.StartScheduledGroupCallRequest(Call))).updates
|
||||
return (await self(
|
||||
functions.phone.StartScheduledGroupCallRequest(Call))
|
||||
).updates
|
||||
else:
|
||||
self._log[__name__].info(
|
||||
"Invalid Method Used while using Modifying GroupCall")
|
||||
|
|
|
@ -144,6 +144,7 @@ GRAPH_OUTDATED_RELOAD,400,"Data can't be used for the channel statistics, graphs
|
|||
GROUPCALL_FORBIDDEN,403,
|
||||
GROUPCALL_JOIN_MISSING,400,
|
||||
GROUPCALL_SSRC_DUPLICATE_MUCH,400,
|
||||
GROUPCALL_NOT_MODIFIED,400
|
||||
GROUPED_MEDIA_INVALID,400,Invalid grouped media
|
||||
GROUP_CALL_INVALID,400,Group call invalid
|
||||
HASH_INVALID,400,The provided hash is invalid
|
||||
|
|
Can't render this file because it has a wrong number of fields in line 147.
|
|
@ -318,6 +318,7 @@ phone.receivedCall,user,CALL_ALREADY_DECLINED CALL_PEER_INVALID
|
|||
phone.requestCall,user,CALL_PROTOCOL_FLAGS_INVALID PARTICIPANT_CALL_FAILED PARTICIPANT_VERSION_OUTDATED USER_ID_INVALID USER_IS_BLOCKED USER_PRIVACY_RESTRICTED
|
||||
phone.saveCallDebug,user,CALL_PEER_INVALID DATA_JSON_INVALID
|
||||
phone.setCallRating,user,CALL_PEER_INVALID
|
||||
phone.toggleGroupCallSettings,user,GROUPCALL_NOT_MODIFIED
|
||||
photos.deletePhotos,user,
|
||||
photos.getUserPhotos,both,MAX_ID_INVALID USER_ID_INVALID
|
||||
photos.updateProfilePhoto,user,PHOTO_ID_INVALID
|
||||
|
|
|
Loading…
Reference in New Issue
Block a user