mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-07 20:42:32 +00:00
Handle all entity types on isinstance checks
Only the uses of `isinstance` against `InputPeer*` types were reviewed. Notably, `utils` is exempt on this because it needs to deal with everything on a case-by-case basis. Since the addition of `*FromMessage` peers, any manual `isinstance` checks to determine the type were prone to breaking or being forgotten to be updated, so a common `helpers._entity_type()` method was made to share this logic. Since the conversion to `Peer` would be too expensive, a simpler check against the name is made, which should be fast and cheap.
This commit is contained in:
@@ -2,7 +2,7 @@ import itertools
|
||||
import re
|
||||
import typing
|
||||
|
||||
from .. import utils
|
||||
from .. import helpers, utils
|
||||
from ..tl import types
|
||||
|
||||
if typing.TYPE_CHECKING:
|
||||
@@ -134,7 +134,7 @@ class MessageParseMethods:
|
||||
id_to_message[update.message.id] = update.message
|
||||
|
||||
elif (isinstance(update, types.UpdateEditMessage)
|
||||
and not isinstance(request.peer, types.InputPeerChannel)):
|
||||
and helpers._entity_type(request.peer) != helpers._EntityType.CHANNEL):
|
||||
if request.id == update.message.id:
|
||||
update.message._finish_init(self, entities, input_chat)
|
||||
return update.message
|
||||
|
Reference in New Issue
Block a user