mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Fix custom parse_mode instances (#4304)
This commit is contained in:
parent
70201a9ff1
commit
41eb665c9d
|
@ -756,7 +756,10 @@ def sanitize_parse_mode(mode):
|
|||
if not mode:
|
||||
return None
|
||||
|
||||
if callable(mode):
|
||||
if (all(hasattr(mode, x) for x in ('parse', 'unparse'))
|
||||
and all(callable(x) for x in (mode.parse, mode.unparse))):
|
||||
return mode
|
||||
elif callable(mode):
|
||||
class CustomMode:
|
||||
@staticmethod
|
||||
def unparse(text, entities):
|
||||
|
@ -764,9 +767,6 @@ def sanitize_parse_mode(mode):
|
|||
|
||||
CustomMode.parse = mode
|
||||
return CustomMode
|
||||
elif (all(hasattr(mode, x) for x in ('parse', 'unparse'))
|
||||
and all(callable(x) for x in (mode.parse, mode.unparse))):
|
||||
return mode
|
||||
elif isinstance(mode, str):
|
||||
try:
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue
Block a user