mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-31 02:09:58 +03:00
Merge branch 'life' of https://github.com/New-dev0/Telethon into life
This commit is contained in:
commit
b687cfbfe1
|
@ -789,8 +789,7 @@ class ChatMethods:
|
||||||
try:
|
try:
|
||||||
action = _ChatAction._str_mapping[action.lower()]
|
action = _ChatAction._str_mapping[action.lower()]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise ValueError(
|
raise ValueError('No such action "{}"'.format(action)) from None
|
||||||
'No such action "{}"'.format(action)) from None
|
|
||||||
elif not isinstance(action, types.TLObject) or action.SUBCLASS_OF_ID != 0x20b2cc21:
|
elif not isinstance(action, types.TLObject) or action.SUBCLASS_OF_ID != 0x20b2cc21:
|
||||||
# 0x20b2cc21 = crc32(b'SendMessageAction')
|
# 0x20b2cc21 = crc32(b'SendMessageAction')
|
||||||
if isinstance(action, type):
|
if isinstance(action, type):
|
||||||
|
@ -955,8 +954,7 @@ class ChatMethods:
|
||||||
entity, user, is_admin=is_admin))
|
entity, user, is_admin=is_admin))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError('You can only edit permissions in groups and channels')
|
||||||
'You can only edit permissions in groups and channels')
|
|
||||||
|
|
||||||
async def edit_permissions(
|
async def edit_permissions(
|
||||||
self: 'TelegramClient',
|
self: 'TelegramClient',
|
||||||
|
@ -1315,85 +1313,27 @@ class ChatMethods:
|
||||||
finally:
|
finally:
|
||||||
await self._return_exported_sender(sender)
|
await self._return_exported_sender(sender)
|
||||||
|
|
||||||
async def modify_groupcall(
|
async def modify_groupcall(self: 'TelegramClient', method:str,
|
||||||
self: 'TelegramClient',
|
chat,
|
||||||
method: str,
|
title:str=None):
|
||||||
entity: 'hints.EntityLike',
|
|
||||||
schedule: 'hints.DateLike' = None,
|
|
||||||
title: str = None
|
|
||||||
):
|
|
||||||
"""
|
|
||||||
Stuff to do with Group Calls, Possible for Administrator and
|
|
||||||
Creator.
|
|
||||||
|
|
||||||
Arguments
|
|
||||||
method (`str`):
|
|
||||||
Any of `create`, `discard`, `start_schedule` and
|
|
||||||
`edit_title` will work. Check Examples to know more Clearly.
|
|
||||||
|
|
||||||
entity (`int` | `str`):
|
|
||||||
Username/ID of Channel, where to Modify Group Call.
|
|
||||||
|
|
||||||
schedule (`hints.Datelike`, optional):
|
|
||||||
Used to Schedule the GroupCall.
|
|
||||||
|
|
||||||
title (str, optional):
|
|
||||||
Edits the Group call Title. It should be used with
|
|
||||||
`edit_title` as method parameter.
|
|
||||||
|
|
||||||
Returns
|
|
||||||
The resulting :tl:`Updates` object.
|
|
||||||
|
|
||||||
Raises
|
|
||||||
ChatAdminRequiredError - You Should be Admin, in order to
|
|
||||||
Modify Group Call.
|
|
||||||
|
|
||||||
Example
|
|
||||||
.. code-block:: python
|
|
||||||
|
|
||||||
# Starting a Group Call
|
|
||||||
await client.modify_groupcall("create", -100123456789)
|
|
||||||
|
|
||||||
# Scheduling a Group Call, within 5-Minutes
|
|
||||||
from datetime import timedelta
|
|
||||||
schedule_for = timedelta(minutes=5)
|
|
||||||
await client.modify_groupcall(
|
|
||||||
"create",
|
|
||||||
schedule=schedule_for
|
|
||||||
)
|
|
||||||
|
|
||||||
# Editing a Group Call Title
|
|
||||||
new_title = "Having Fun with Telethon"
|
|
||||||
await client.modify_groupcall(
|
|
||||||
"edit_title",
|
|
||||||
title=new_title
|
|
||||||
)
|
|
||||||
|
|
||||||
# Stopping/Closing a Group Call
|
|
||||||
await client.modify_groupcall("discard", -100123456789)
|
|
||||||
"""
|
|
||||||
if not method:
|
if not method:
|
||||||
return self._log[__name__].info("Method Cant be None.")
|
return
|
||||||
|
if method == "create":
|
||||||
if method == "create" :
|
InputPeer = utils.get_input_peer(chat)
|
||||||
return await self(
|
return await self(
|
||||||
functions.phone.CreateGroupCallRequest(
|
functions.phone.CreateGroupCallRequest(peer=InputPeer)
|
||||||
peer=entity,
|
)
|
||||||
schedule=schedule)
|
|
||||||
).updates[0]
|
|
||||||
try:
|
try:
|
||||||
Call = await self(functions.messages.GetFullChatRequest(entity))
|
Call = (await self(functions.messages.GetFullChatRequest(chat))).full_chat.call
|
||||||
except errors.rpcerrorlist.ChatIdInvalidError:
|
except errors.rpcerrorlist.ChatIdInvalidError:
|
||||||
Call = await self(functions. channels.GetFullChannelRequest(entity))
|
Call = (await self(functions.channels.GetFullChannelRequest(chat))).full_chat.call
|
||||||
if method == "edit_title":
|
if method == "edit_title":
|
||||||
return (await self(functions.phone.EditGroupCallTitleRequest(
|
return await self(functions.phone.EditGroupCallTitleRequest(Call, title=title))
|
||||||
Call, title=title if title else ""))).updates
|
|
||||||
elif method == "discard":
|
elif method == "discard":
|
||||||
return (await self(functions.phone.DiscardGroupCallRequest(Call))).updates
|
return await self(functions.phone.DiscardGroupCallRequest(call))
|
||||||
elif method == "start_schedule":
|
|
||||||
return (await self(functions.phone.StartScheduledGroupCallRequest(Call))).updates
|
|
||||||
else:
|
else:
|
||||||
self._log[__name__].info(
|
self._log[__name__].info("Invalid Method Invoked while using change_groupcall")
|
||||||
"Invalid Method Used while using Modifying GroupCall")
|
|
||||||
|
|
||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
Loading…
Reference in New Issue
Block a user