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(
|
async def get_permissions(
|
||||||
self: 'TelegramClient',
|
self: 'TelegramClient',
|
||||||
entity: 'hints.EntityLike',
|
entity: 'hints.EntityLike',
|
||||||
user: 'hints.EntityLike'
|
user: 'hints.EntityLike' = None
|
||||||
) -> 'typing.Optional[custom.ParticipantPermissions]':
|
) -> '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::
|
.. note::
|
||||||
|
|
||||||
|
@ -1199,7 +1201,7 @@ class ChatMethods:
|
||||||
entity (`entity`):
|
entity (`entity`):
|
||||||
The channel or chat the user is participant of.
|
The channel or chat the user is participant of.
|
||||||
|
|
||||||
user (`entity`):
|
user (`entity`, optional):
|
||||||
Target user.
|
Target user.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
|
@ -1213,8 +1215,19 @@ class ChatMethods:
|
||||||
permissions = await client.get_permissions(chat, user)
|
permissions = await client.get_permissions(chat, user)
|
||||||
if permissions.is_admin:
|
if permissions.is_admin:
|
||||||
# do something
|
# do something
|
||||||
|
|
||||||
|
# Get Banned Permissions of Chat
|
||||||
|
await client.get_permissions(chat)
|
||||||
"""
|
"""
|
||||||
entity = await self.get_input_entity(entity)
|
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)
|
user = await self.get_input_entity(user)
|
||||||
if helpers._entity_type(user) != helpers._EntityType.USER:
|
if helpers._entity_type(user) != helpers._EntityType.USER:
|
||||||
raise ValueError('You must pass a user entity')
|
raise ValueError('You must pass a user entity')
|
||||||
|
@ -1320,8 +1333,10 @@ class ChatMethods:
|
||||||
method: str,
|
method: str,
|
||||||
entity: 'hints.EntityLike',
|
entity: 'hints.EntityLike',
|
||||||
schedule: 'hints.DateLike' = None,
|
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
|
Stuff to do with Group Calls, Possible for Administrator and
|
||||||
Creator.
|
Creator.
|
||||||
|
@ -1332,28 +1347,43 @@ class ChatMethods:
|
||||||
`edit_title` will work. Check Examples to know more Clearly.
|
`edit_title` will work. Check Examples to know more Clearly.
|
||||||
|
|
||||||
entity (`int` | `str`):
|
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.
|
Used to Schedule the GroupCall.
|
||||||
|
|
||||||
title (str, optional):
|
title (`str`, `optional`):
|
||||||
Edits the Group call Title. It should be used with
|
Edits the Group call Title. It should be used with
|
||||||
`edit_title` as method parameter.
|
`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
|
Returns
|
||||||
The resulting :tl:`Updates` object.
|
The resulting :tl:`Updates` object.
|
||||||
|
|
||||||
Raises
|
Raises
|
||||||
ChatAdminRequiredError - You Should be Admin, in order to
|
ChatAdminRequiredError - You Should be Admin, in order to
|
||||||
Modify Group Call.
|
Modify Group Call.
|
||||||
|
|
||||||
Example
|
Example
|
||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
# Starting a Group Call
|
# Starting a Group Call
|
||||||
await client.modify_groupcall("create", -100123456789)
|
await client.modify_groupcall("create", -100123456789)
|
||||||
|
|
||||||
# Scheduling a Group Call, within 5-Minutes
|
# Scheduling a Group Call, within 5-Minutes
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
schedule_for = timedelta(minutes=5)
|
schedule_for = timedelta(minutes=5)
|
||||||
|
@ -1361,7 +1391,7 @@ class ChatMethods:
|
||||||
"create",
|
"create",
|
||||||
schedule=schedule_for
|
schedule=schedule_for
|
||||||
)
|
)
|
||||||
|
|
||||||
# Editing a Group Call Title
|
# Editing a Group Call Title
|
||||||
new_title = "Having Fun with Telethon"
|
new_title = "Having Fun with Telethon"
|
||||||
await client.modify_groupcall(
|
await client.modify_groupcall(
|
||||||
|
@ -1371,27 +1401,48 @@ class ChatMethods:
|
||||||
|
|
||||||
# Stopping/Closing a Group Call
|
# Stopping/Closing a Group Call
|
||||||
await client.modify_groupcall("discard", -100123456789)
|
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:
|
if not method:
|
||||||
return self._log[__name__].info("Method Cant be None.")
|
return self._log[__name__].info("Method Cant be None.")
|
||||||
|
|
||||||
if method == "create" :
|
if method == "create":
|
||||||
return await self(
|
return await self(
|
||||||
functions.phone.CreateGroupCallRequest(
|
functions.phone.CreateGroupCallRequest(
|
||||||
peer=entity,
|
peer=entity,
|
||||||
schedule=schedule)
|
schedule=schedule)
|
||||||
).updates[0]
|
).updates[0]
|
||||||
try:
|
try:
|
||||||
Call = await self(functions.messages.GetFullChatRequest(entity))
|
Call = await self(
|
||||||
|
functions.messages.GetFullChatRequest(entity))
|
||||||
except errors.rpcerrorlist.ChatIdInvalidError:
|
except errors.rpcerrorlist.ChatIdInvalidError:
|
||||||
Call = await self(functions. channels.GetFullChannelRequest(entity))
|
Call = await self(
|
||||||
|
functions.channels.GetFullChannelRequest(entity))
|
||||||
if method == "edit_title":
|
if method == "edit_title":
|
||||||
return (await self(functions.phone.EditGroupCallTitleRequest(
|
return (await self(functions.phone.EditGroupCallTitleRequest(
|
||||||
Call, title=title if title else ""))).updates
|
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":
|
elif method == "discard":
|
||||||
return (await self(functions.phone.DiscardGroupCallRequest(Call))).updates
|
return (await self(
|
||||||
|
functions.phone.DiscardGroupCallRequest(Call))).updates
|
||||||
elif method == "start_schedule":
|
elif method == "start_schedule":
|
||||||
return (await self(functions.phone.StartScheduledGroupCallRequest(Call))).updates
|
return (await self(
|
||||||
|
functions.phone.StartScheduledGroupCallRequest(Call))
|
||||||
|
).updates
|
||||||
else:
|
else:
|
||||||
self._log[__name__].info(
|
self._log[__name__].info(
|
||||||
"Invalid Method Used while using Modifying GroupCall")
|
"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_FORBIDDEN,403,
|
||||||
GROUPCALL_JOIN_MISSING,400,
|
GROUPCALL_JOIN_MISSING,400,
|
||||||
GROUPCALL_SSRC_DUPLICATE_MUCH,400,
|
GROUPCALL_SSRC_DUPLICATE_MUCH,400,
|
||||||
|
GROUPCALL_NOT_MODIFIED,400
|
||||||
GROUPED_MEDIA_INVALID,400,Invalid grouped media
|
GROUPED_MEDIA_INVALID,400,Invalid grouped media
|
||||||
GROUP_CALL_INVALID,400,Group call invalid
|
GROUP_CALL_INVALID,400,Group call invalid
|
||||||
HASH_INVALID,400,The provided hash is 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.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.saveCallDebug,user,CALL_PEER_INVALID DATA_JSON_INVALID
|
||||||
phone.setCallRating,user,CALL_PEER_INVALID
|
phone.setCallRating,user,CALL_PEER_INVALID
|
||||||
|
phone.toggleGroupCallSettings,user,GROUPCALL_NOT_MODIFIED
|
||||||
photos.deletePhotos,user,
|
photos.deletePhotos,user,
|
||||||
photos.getUserPhotos,both,MAX_ID_INVALID USER_ID_INVALID
|
photos.getUserPhotos,both,MAX_ID_INVALID USER_ID_INVALID
|
||||||
photos.updateProfilePhoto,user,PHOTO_ID_INVALID
|
photos.updateProfilePhoto,user,PHOTO_ID_INVALID
|
||||||
|
|
|
Loading…
Reference in New Issue
Block a user