mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-02-03 21:24:35 +03:00
Actually make AdminLogEvent work
Ideally this would have been tested before release one commit ago.
This commit is contained in:
parent
77be6a2755
commit
c51a17bf9a
|
@ -322,8 +322,17 @@ class ChatMethods(UserMethods):
|
||||||
for x in itertools.chain(result.users, result.chats)}
|
for x in itertools.chain(result.users, result.chats)}
|
||||||
|
|
||||||
request.max_id = min((e.id for e in result.events), default=0)
|
request.max_id = min((e.id for e in result.events), default=0)
|
||||||
for event in result.events:
|
for ev in result.events:
|
||||||
await yield_(custom.AdminLogEvent(event, entities))
|
if isinstance(ev.action,
|
||||||
|
types.ChannelAdminLogEventActionEditMessage):
|
||||||
|
ev.action.prev_message._finish_init(self, entities, entity)
|
||||||
|
ev.action.new_message._finish_init(self, entities, entity)
|
||||||
|
|
||||||
|
elif isinstance(ev.action,
|
||||||
|
types.ChannelAdminLogEventActionDeleteMessage):
|
||||||
|
ev.action.message._finish_init(self, entities, entity)
|
||||||
|
|
||||||
|
await yield_(custom.AdminLogEvent(ev, entities))
|
||||||
|
|
||||||
if len(result.events) < request.limit:
|
if len(result.events) < request.limit:
|
||||||
break
|
break
|
||||||
|
|
|
@ -62,7 +62,7 @@ class AdminLogEvent:
|
||||||
"""
|
"""
|
||||||
The old value from the event.
|
The old value from the event.
|
||||||
"""
|
"""
|
||||||
ori = self.original
|
ori = self.original.action
|
||||||
if isinstance(ori, (
|
if isinstance(ori, (
|
||||||
types.ChannelAdminLogEventActionChangeAbout,
|
types.ChannelAdminLogEventActionChangeAbout,
|
||||||
types.ChannelAdminLogEventActionChangeTitle,
|
types.ChannelAdminLogEventActionChangeTitle,
|
||||||
|
@ -94,7 +94,7 @@ class AdminLogEvent:
|
||||||
"""
|
"""
|
||||||
The new value present in the event.
|
The new value present in the event.
|
||||||
"""
|
"""
|
||||||
ori = self.original
|
ori = self.original.action
|
||||||
if isinstance(ori, (
|
if isinstance(ori, (
|
||||||
types.ChannelAdminLogEventActionChangeAbout,
|
types.ChannelAdminLogEventActionChangeAbout,
|
||||||
types.ChannelAdminLogEventActionChangeTitle,
|
types.ChannelAdminLogEventActionChangeTitle,
|
||||||
|
@ -125,7 +125,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``str``.
|
If ``True``, `old` and `new` will be present as ``str``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionChangeAbout)
|
types.ChannelAdminLogEventActionChangeAbout)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -135,7 +135,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``str``.
|
If ``True``, `old` and `new` will be present as ``str``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionChangeTitle)
|
types.ChannelAdminLogEventActionChangeTitle)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -145,7 +145,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``str``.
|
If ``True``, `old` and `new` will be present as ``str``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionChangeUsername)
|
types.ChannelAdminLogEventActionChangeUsername)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -155,7 +155,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as :tl:`ChatPhoto`.
|
If ``True``, `old` and `new` will be present as :tl:`ChatPhoto`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionChangePhoto)
|
types.ChannelAdminLogEventActionChangePhoto)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -165,7 +165,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as :tl:`InputStickerSet`.
|
If ``True``, `old` and `new` will be present as :tl:`InputStickerSet`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionChangeStickerSet)
|
types.ChannelAdminLogEventActionChangeStickerSet)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -176,7 +176,7 @@ class AdminLogEvent:
|
||||||
If ``True``, `old` and `new` will be present as
|
If ``True``, `old` and `new` will be present as
|
||||||
`Message <telethon.tl.custom.message.Message>`.
|
`Message <telethon.tl.custom.message.Message>`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionEditMessage)
|
types.ChannelAdminLogEventActionEditMessage)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -187,7 +187,7 @@ class AdminLogEvent:
|
||||||
If ``True``, `old` will be present as
|
If ``True``, `old` will be present as
|
||||||
`Message <telethon.tl.custom.message.Message>`.
|
`Message <telethon.tl.custom.message.Message>`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionDeleteMessage)
|
types.ChannelAdminLogEventActionDeleteMessage)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -200,7 +200,7 @@ class AdminLogEvent:
|
||||||
:tl:`ChannelParticipant`.
|
:tl:`ChannelParticipant`.
|
||||||
"""
|
"""
|
||||||
return isinstance(
|
return isinstance(
|
||||||
self.original,
|
self.original.action,
|
||||||
types.ChannelAdminLogEventActionParticipantToggleAdmin)
|
types.ChannelAdminLogEventActionParticipantToggleAdmin)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -212,7 +212,7 @@ class AdminLogEvent:
|
||||||
:tl:`ChannelParticipant`.
|
:tl:`ChannelParticipant`.
|
||||||
"""
|
"""
|
||||||
return isinstance(
|
return isinstance(
|
||||||
self.original,
|
self.original.action,
|
||||||
types.ChannelAdminLogEventActionParticipantToggleBan)
|
types.ChannelAdminLogEventActionParticipantToggleBan)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -222,7 +222,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``bool``.
|
If ``True``, `old` and `new` will be present as ``bool``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionToggleInvites)
|
types.ChannelAdminLogEventActionToggleInvites)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -231,7 +231,7 @@ class AdminLogEvent:
|
||||||
Whether `user` joined through the channel's
|
Whether `user` joined through the channel's
|
||||||
public username in this event or not.
|
public username in this event or not.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionParticipantJoin)
|
types.ChannelAdminLogEventActionParticipantJoin)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -243,7 +243,7 @@ class AdminLogEvent:
|
||||||
If ``True``, `new` will be present as
|
If ``True``, `new` will be present as
|
||||||
:tl:`ChannelParticipant`.
|
:tl:`ChannelParticipant`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionParticipantInvite)
|
types.ChannelAdminLogEventActionParticipantInvite)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -251,7 +251,7 @@ class AdminLogEvent:
|
||||||
"""
|
"""
|
||||||
Whether `user` left the channel in this event or not.
|
Whether `user` left the channel in this event or not.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionParticipantLeave)
|
types.ChannelAdminLogEventActionParticipantLeave)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -262,7 +262,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``bool``.
|
If ``True``, `old` and `new` will be present as ``bool``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionTogglePreHistoryHidden)
|
types.ChannelAdminLogEventActionTogglePreHistoryHidden)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -273,7 +273,7 @@ class AdminLogEvent:
|
||||||
|
|
||||||
If ``True``, `old` and `new` will be present as ``bool``.
|
If ``True``, `old` and `new` will be present as ``bool``.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionToggleSignatures)
|
types.ChannelAdminLogEventActionToggleSignatures)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -284,7 +284,7 @@ class AdminLogEvent:
|
||||||
If ``True``, `new` will be present as
|
If ``True``, `new` will be present as
|
||||||
`Message <telethon.tl.custom.message.Message>`.
|
`Message <telethon.tl.custom.message.Message>`.
|
||||||
"""
|
"""
|
||||||
return isinstance(self.original,
|
return isinstance(self.original.action,
|
||||||
types.ChannelAdminLogEventActionUpdatePinned)
|
types.ChannelAdminLogEventActionUpdatePinned)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user