bug fix: made send_message function coroutine

Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
klux2 2019-05-12 22:00:10 +02:00
parent 53c742035b
commit 4f0cc4106c

View file

@ -120,21 +120,21 @@ async def send_essen(chat_id: int) -> None:
nachricht = nachricht.replace("MONAT", monate[(datum.month - 1) % 12]) nachricht = nachricht.replace("MONAT", monate[(datum.month - 1) % 12])
for i in essen: for i in essen:
nachricht += "- " + str(i).replace(".", ",") + "\n\n" nachricht += "- " + str(i).replace(".", ",") + "\n\n"
send_message(bot_obj=bot, chat_id=chat_id, msg=nachricht, parse_mode="markdown") await send_message(bot_obj=bot, chat_id=chat_id, msg=nachricht, parse_mode="markdown")
async def send_status(text: str) -> None: async def send_status(text: str) -> None:
global config_ids global config_ids
for chat_id in config_ids: for chat_id in config_ids:
send_message(bot_obj=bot, chat_id=chat_id, msg=text) await send_message(bot_obj=bot, chat_id=chat_id, msg=text)
def send_message(bot_obj: DelegatorBot, chat_id: int, msg: str, parse_mode: Any = None, async def send_message(bot_obj: DelegatorBot, chat_id: int, msg: str, parse_mode: Any = None,
disable_web_page_preview: bool = None, disable_notification: bool = None, disable_web_page_preview: bool = None, disable_notification: bool = None,
reply_to_message_id: int = None, reply_markup: Any = None) -> None: reply_to_message_id: int = None, reply_markup: Any = None) -> None:
"""Sends a message with bot_obj to chat_id. See https://core.telegram.org/bots/api#sendmessage for details.""" """Sends a message with bot_obj to chat_id. See https://core.telegram.org/bots/api#sendmessage for details."""
try: try:
bot_obj.sendMessage(chat_id=chat_id, text=msg, parse_mode=parse_mode, await bot_obj.sendMessage(chat_id=chat_id, text=msg, parse_mode=parse_mode,
disable_web_page_preview=disable_web_page_preview, disable_web_page_preview=disable_web_page_preview,
disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, disable_notification=disable_notification, reply_to_message_id=reply_to_message_id,
reply_markup=reply_markup) reply_markup=reply_markup)
@ -143,7 +143,7 @@ def send_message(bot_obj: DelegatorBot, chat_id: int, msg: str, parse_mode: Any
ids.remove(chat_id) ids.remove(chat_id)
config['ids'] = ids config['ids'] = ids
await send_status("Bot wurde blockiert für Chat ID %i)" % chat_id) await send_status("Bot wurde blockiert für Chat ID %i" % chat_id)
write_config() write_config()