mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-30 01:39:47 +03:00
so finally
Thanks PC
This commit is contained in:
parent
c48e8b98cc
commit
c43019ad36
|
@ -789,7 +789,8 @@ class ChatMethods:
|
|||
try:
|
||||
action = _ChatAction._str_mapping[action.lower()]
|
||||
except KeyError:
|
||||
raise ValueError('No such action "{}"'.format(action)) from None
|
||||
raise ValueError(
|
||||
'No such action "{}"'.format(action)) from None
|
||||
elif not isinstance(action, types.TLObject) or action.SUBCLASS_OF_ID != 0x20b2cc21:
|
||||
# 0x20b2cc21 = crc32(b'SendMessageAction')
|
||||
if isinstance(action, type):
|
||||
|
@ -954,7 +955,8 @@ class ChatMethods:
|
|||
entity, user, is_admin=is_admin))
|
||||
|
||||
else:
|
||||
raise ValueError('You can only edit permissions in groups and channels')
|
||||
raise ValueError(
|
||||
'You can only edit permissions in groups and channels')
|
||||
|
||||
async def edit_permissions(
|
||||
self: 'TelegramClient',
|
||||
|
@ -1313,27 +1315,85 @@ class ChatMethods:
|
|||
finally:
|
||||
await self._return_exported_sender(sender)
|
||||
|
||||
async def change_groupcall(method:str,
|
||||
chat,
|
||||
title:str=None):
|
||||
if not method:
|
||||
return
|
||||
if method == "create":
|
||||
InputPeer = utils.get_input_peer(chat)
|
||||
return await self(
|
||||
functions.phone.CreateGroupCallRequest(peer=InputPeer)
|
||||
)
|
||||
try:
|
||||
Call = (await self(functions.messages.GetFullChatRequest(chat))).full_chat.call
|
||||
except errors.rpcerrorlist.ChatIdInvalidError:
|
||||
Call = (await self(functions.channels.GetFullChannelRequest(chat))).full_chat.call
|
||||
if method == "edit_title":
|
||||
return await self(functions.phone.EditGroupCallTitleRequest(Call, title=title))
|
||||
elif method == "discard":
|
||||
return await self(functions.phone.DiscardGroupCallRequest(call))
|
||||
else:
|
||||
self._log[__name__].info("Invalid Method Invoked while using change_groupcall")
|
||||
async def modify_groupcall(
|
||||
self: 'TelegramClient',
|
||||
method: str,
|
||||
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
|
||||
|
||||
# endregion
|
||||
# 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:
|
||||
return self._log[__name__].info("Method Cant be None.")
|
||||
|
||||
if method == "create" :
|
||||
return await self(
|
||||
functions.phone.CreateGroupCallRequest(
|
||||
peer=entity,
|
||||
schedule=schedule)
|
||||
).updates[0]
|
||||
try:
|
||||
Call = await self(functions.messages.GetFullChatRequest(entity))
|
||||
except errors.rpcerrorlist.ChatIdInvalidError:
|
||||
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 == "discard":
|
||||
return (await self(functions.phone.DiscardGroupCallRequest(Call))).updates
|
||||
elif method == "start_schedule":
|
||||
return (await self(functions.phone.StartScheduledGroupCallRequest(Call))).updates
|
||||
else:
|
||||
self._log[__name__].info(
|
||||
"Invalid Method Used while using Modifying GroupCall")
|
||||
|
||||
# endregion
|
||||
|
|
|
@ -216,6 +216,7 @@ PACK_SHORT_NAME_INVALID,400,"Invalid sticker pack name. It must begin with a let
|
|||
PACK_SHORT_NAME_OCCUPIED,400,A stickerpack with this name already exists
|
||||
PARTICIPANTS_TOO_FEW,400,Not enough participants
|
||||
PARTICIPANT_CALL_FAILED,500,Failure while making call
|
||||
PARTICIPANT_JOIN_MISSING,403,
|
||||
PARTICIPANT_VERSION_OUTDATED,400,The other participant does not use an up to date telegram client with support for calls
|
||||
PASSWORD_EMPTY,400,The provided password is empty
|
||||
PASSWORD_HASH_INVALID,400,The password (and thus its hash value) you entered is invalid
|
||||
|
@ -288,6 +289,7 @@ RPC_CALL_FAIL,500,"Telegram is having internal issues, please try again later."
|
|||
RPC_MCGET_FAIL,500,"Telegram is having internal issues, please try again later."
|
||||
RSA_DECRYPT_FAILED,400,Internal RSA decryption failed
|
||||
SCHEDULE_BOT_NOT_ALLOWED,400,Bots are not allowed to schedule messages
|
||||
SCHEDULE_DATE_INVALID,400,
|
||||
SCHEDULE_DATE_TOO_LATE,400,The date you tried to schedule is too far in the future (last known limit of 1 year and a few hours)
|
||||
SCHEDULE_STATUS_PRIVATE,400,You cannot schedule a message until the person comes online if their privacy does not show this information
|
||||
SCHEDULE_TOO_MUCH,400,You cannot schedule more messages in this chat (last known limit of 100 per chat)
|
||||
|
|
|
|
@ -308,10 +308,12 @@ payments.sendPaymentForm,user,MESSAGE_ID_INVALID
|
|||
payments.validateRequestedInfo,user,MESSAGE_ID_INVALID
|
||||
phone.acceptCall,user,CALL_ALREADY_ACCEPTED CALL_ALREADY_DECLINED CALL_OCCUPY_FAILED CALL_PEER_INVALID CALL_PROTOCOL_FLAGS_INVALID
|
||||
phone.confirmCall,user,CALL_ALREADY_DECLINED CALL_PEER_INVALID
|
||||
phone.createGroupCall,user,SCHEDULE_DATE_INVALID
|
||||
phone.discardCall,user,CALL_ALREADY_ACCEPTED CALL_PEER_INVALID
|
||||
phone.getCallConfig,user,
|
||||
phone.inviteToGroupCall,user,GROUPCALL_FORBIDDEN
|
||||
phone.joinGroupCall,user,GROUPCALL_SSRC_DUPLICATE_MUCH
|
||||
phone.joinGroupCallPresentation,403, PARTICIPANT_JOIN_MISSING
|
||||
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
|
||||
|
|
|
Loading…
Reference in New Issue
Block a user