mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-25 10:53:44 +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:
|
if not mode:
|
||||||
return None
|
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:
|
class CustomMode:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def unparse(text, entities):
|
def unparse(text, entities):
|
||||||
|
@ -764,9 +767,6 @@ def sanitize_parse_mode(mode):
|
||||||
|
|
||||||
CustomMode.parse = mode
|
CustomMode.parse = mode
|
||||||
return CustomMode
|
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):
|
elif isinstance(mode, str):
|
||||||
try:
|
try:
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user