Example #1
0
async def notif():
    with Session as session:
        for u in session.query(User).all():
            try:
                nt = u.get_notif()
            except Exception as e:
                logger.error(e)
            else:
                if nt:
                    await bot.send_message(u.id,
                                           lang(u, "notif_event") + str(nt),
                                           parse_mode=ParseMode.MARKDOWN)
        session.commit()
Example #2
0
def unload_module(module: str) -> bool:
    try:
        module = import_module(f"TelegramEDT.{module}")
    except ModuleNotFoundError:
        logger.error(f"Fail to unload module {module}, module not found !")
        return False
    else:
        try:
            module.unload()
        except AttributeError:
            logger.error(f"Fail to unload module {module}, no unload function !")
            return False
    return True
Example #3
0
async def notif():
    with Session as session:
        for u in session.query(User).all():
            try:
                kf = u.get_kfet()
            except Exception as e:
                logger.error(e)
            else:
                if kf is not None:
                    if kf == 1:
                        kf = lang(u, "kfet")
                    elif kf == 2:
                        kf = lang(u, "kfet_prb")
                    else:
                        kf = lang(u, "kfet_err")
                    await bot.send_message(u.id,
                                           kf,
                                           parse_mode=ParseMode.MARKDOWN)
                    session.commit()
Example #4
0
async def notif():
    with Session as session:
        for u in session.query(User).all():
            try:
                tm = u.get_tomuss()
            except Exception as e:
                logger.error(e)
            else:
                if tm:
                    for i in tm:
                        msg = markdown.text(
                            markdown.bold(i.title),
                            markdown.code(
                                i.summary.replace("<br>", "\n").replace(
                                    "<b>", "").replace("</b>", "")),
                            sep="\n")
                        await bot.send_message(u.id,
                                               msg,
                                               parse_mode=ParseMode.MARKDOWN)
                    u.tomuss_last = str(i)
                    session.commit()