added possibility to send messages even with logging disabled
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
0e9cc463c1
commit
02e6a96e11
1 changed files with 14 additions and 3 deletions
|
@ -138,9 +138,15 @@ async def send_essen(chat_id: int) -> None:
|
|||
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, ignore_flag: bool = False) -> None:
|
||||
"""
|
||||
Sends a status message to all chats specified in config_ids
|
||||
:param text: Message
|
||||
:param ignore_flag: Should the logging_enabled flag be ignored (should a message be sent even if it is set to False)?
|
||||
:return:
|
||||
"""
|
||||
global config_ids
|
||||
if logging_enabled:
|
||||
if ignore_flag or logging_enabled:
|
||||
for chat_id in config_ids:
|
||||
await send_message(bot_obj=bot, chat_id=chat_id, msg=text)
|
||||
|
||||
|
@ -170,6 +176,11 @@ def write_config() -> None:
|
|||
|
||||
|
||||
async def get_essen(only_today: bool) -> None:
|
||||
"""
|
||||
Downloads the plan for the next day and parses it
|
||||
:param only_today: only current day; no download if the mensa is closed
|
||||
:return:
|
||||
"""
|
||||
global datum, essen, var # , ctx
|
||||
essen = []
|
||||
try:
|
||||
|
@ -179,7 +190,7 @@ async def get_essen(only_today: bool) -> None:
|
|||
var = False
|
||||
return
|
||||
except Exception as expt:
|
||||
await send_status("Es ist ein Fehler aufgetreten:\n%s" % str(expt))
|
||||
await send_status("Es ist ein Fehler aufgetreten:\n%s" % str(expt), ignore_flag=True)
|
||||
print("Fehler:\n%s" % str(expt))
|
||||
var = True
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue