Add default parse mode

This commit is contained in:
jrootjunior 2019-12-03 13:10:09 +02:00
parent 62bce34b49
commit aa7c5796dd
9 changed files with 54 additions and 6 deletions

View file

@ -65,6 +65,23 @@ class TelegramMethod(abc.ABC, BaseModel, Generic[T]):
else:
data[name] = value
def prepare_parse_mode(self, root: Any) -> None:
if isinstance(root, list):
for item in root:
self.prepare_parse_mode(item)
return
if "parse_mode" not in root:
return
from ..client.bot import Bot
bot = Bot.get_current(no_error=True)
if bot and bot.parse_mode:
root["parse_mode"] = bot.parse_mode
return
return
async def emit(self, bot: Bot) -> T:
return await bot.emit(self)