mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-11-12 03:50:39 +00:00
@@ -221,15 +221,17 @@ class _AdminLogIter(RequestIter):
|
||||
async def _init(
|
||||
self, entity, admins, search, min_id, max_id,
|
||||
join, leave, invite, restrict, unrestrict, ban, unban,
|
||||
promote, demote, info, settings, pinned, edit, delete
|
||||
promote, demote, info, settings, pinned, edit, delete,
|
||||
group_call
|
||||
):
|
||||
if any((join, leave, invite, restrict, unrestrict, ban, unban,
|
||||
promote, demote, info, settings, pinned, edit, delete)):
|
||||
promote, demote, info, settings, pinned, edit, delete,
|
||||
group_call)):
|
||||
events_filter = types.ChannelAdminLogEventsFilter(
|
||||
join=join, leave=leave, invite=invite, ban=restrict,
|
||||
unban=unrestrict, kick=ban, unkick=unban, promote=promote,
|
||||
demote=demote, info=info, settings=settings, pinned=pinned,
|
||||
edit=edit, delete=delete
|
||||
edit=edit, delete=delete, group_call=group_call
|
||||
)
|
||||
else:
|
||||
events_filter = None
|
||||
@@ -495,7 +497,8 @@ class ChatMethods:
|
||||
settings: bool = None,
|
||||
pinned: bool = None,
|
||||
edit: bool = None,
|
||||
delete: bool = None) -> _AdminLogIter:
|
||||
delete: bool = None,
|
||||
group_call: bool = None) -> _AdminLogIter:
|
||||
"""
|
||||
Iterator over the admin log for the specified channel.
|
||||
|
||||
@@ -582,6 +585,9 @@ class ChatMethods:
|
||||
delete (`bool`):
|
||||
If `True`, events of message deletions will be returned.
|
||||
|
||||
group_call (`bool`):
|
||||
If `True`, events related to group calls will be returned.
|
||||
|
||||
Yields
|
||||
Instances of `AdminLogEvent <telethon.tl.custom.adminlogevent.AdminLogEvent>`.
|
||||
|
||||
@@ -613,7 +619,8 @@ class ChatMethods:
|
||||
settings=settings,
|
||||
pinned=pinned,
|
||||
edit=edit,
|
||||
delete=delete
|
||||
delete=delete,
|
||||
group_call=group_call
|
||||
)
|
||||
|
||||
async def get_admin_log(
|
||||
@@ -811,6 +818,7 @@ class ChatMethods:
|
||||
invite_users: bool = None,
|
||||
pin_messages: bool = None,
|
||||
add_admins: bool = None,
|
||||
manage_call: bool = True,
|
||||
anonymous: bool = None,
|
||||
is_admin: bool = None,
|
||||
title: str = None) -> types.Updates:
|
||||
@@ -855,6 +863,9 @@ class ChatMethods:
|
||||
add_admins (`bool`, optional):
|
||||
Whether the user will be able to add admins.
|
||||
|
||||
manage_call (`bool`, optional):
|
||||
Whether the user will be able to manage group calls.
|
||||
|
||||
anonymous (`bool`, optional):
|
||||
Whether the user will remain anonymous when sending messages.
|
||||
The sender of the anonymous messages becomes the group itself.
|
||||
@@ -907,7 +918,7 @@ class ChatMethods:
|
||||
perm_names = (
|
||||
'change_info', 'post_messages', 'edit_messages', 'delete_messages',
|
||||
'ban_users', 'invite_users', 'pin_messages', 'add_admins',
|
||||
'anonymous',
|
||||
'anonymous', 'manage_call',
|
||||
)
|
||||
|
||||
ty = helpers._entity_type(entity)
|
||||
|
||||
@@ -91,6 +91,8 @@ class AdminLogEvent:
|
||||
return ori.message
|
||||
elif isinstance(ori, types.ChannelAdminLogEventActionDefaultBannedRights):
|
||||
return ori.prev_banned_rights
|
||||
elif isinstance(ori, types.ChannelAdminLogEventActionDiscardGroupCall):
|
||||
return ori.call
|
||||
|
||||
@property
|
||||
def new(self):
|
||||
@@ -125,6 +127,15 @@ class AdminLogEvent:
|
||||
return ori.new_banned_rights
|
||||
elif isinstance(ori, types.ChannelAdminLogEventActionStopPoll):
|
||||
return ori.message
|
||||
elif isinstance(ori, types.ChannelAdminLogEventActionStartGroupCall):
|
||||
return ori.call
|
||||
elif isinstance(ori, (
|
||||
types.ChannelAdminLogEventActionParticipantMute,
|
||||
types.ChannelAdminLogEventActionParticipantUnmute,
|
||||
)):
|
||||
return ori.participant
|
||||
elif isinstance(ori, types.ChannelAdminLogEventActionToggleGroupCallSetting):
|
||||
return ori.join_muted
|
||||
|
||||
@property
|
||||
def changed_about(self):
|
||||
@@ -327,6 +338,56 @@ class AdminLogEvent:
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionStopPoll)
|
||||
|
||||
@property
|
||||
def started_group_call(self):
|
||||
"""
|
||||
Whether a group call was started or not.
|
||||
|
||||
If `True`, `new` will be present as :tl:`InputGroupCall`.
|
||||
"""
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionStartGroupCall)
|
||||
|
||||
@property
|
||||
def discarded_group_call(self):
|
||||
"""
|
||||
Whether a group call was started or not.
|
||||
|
||||
If `True`, `old` will be present as :tl:`InputGroupCall`.
|
||||
"""
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionDiscardGroupCall)
|
||||
|
||||
@property
|
||||
def user_muted(self):
|
||||
"""
|
||||
Whether a participant was muted in the ongoing group call or not.
|
||||
|
||||
If `True`, `new` will be present as :tl:`GroupCallParticipant`.
|
||||
"""
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionParticipantMute)
|
||||
|
||||
@property
|
||||
def user_unmutted(self):
|
||||
"""
|
||||
Whether a participant was unmuted from the ongoing group call or not.
|
||||
|
||||
If `True`, `new` will be present as :tl:`GroupCallParticipant`.
|
||||
"""
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionParticipantUnmute)
|
||||
|
||||
@property
|
||||
def changed_call_settings(self):
|
||||
"""
|
||||
Whether the group call settings were changed or not.
|
||||
|
||||
If `True`, `new` will be `True` if new users are muted on join.
|
||||
"""
|
||||
return isinstance(self.original.action,
|
||||
types.ChannelAdminLogEventActionToggleGroupCallSetting)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.original)
|
||||
|
||||
|
||||
@@ -564,6 +564,17 @@ def get_input_message(message):
|
||||
_raise_cast_fail(message, 'InputMedia')
|
||||
|
||||
|
||||
def get_input_group_call(call):
|
||||
"""Similar to :meth:`get_input_peer`, but for input calls."""
|
||||
try:
|
||||
if call.SUBCLASS_OF_ID == 0x58611ab1: # crc32(b'InputGroupCall')
|
||||
return call
|
||||
elif call.SUBCLASS_OF_ID == 0x20b4f320: # crc32(b'GroupCall')
|
||||
return types.InputGroupCall(id=call.id, access_hash=call.access_hash)
|
||||
except AttributeError:
|
||||
_raise_cast_fail(call, 'InputGroupCall')
|
||||
|
||||
|
||||
def _get_entity_pair(entity_id, entities, cache,
|
||||
get_input_peer=get_input_peer):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user