def init_rich_menu_first():
    """
    Initialize rich menu API. Check also: attendance_management_bot/externals/richmenu.py

        reference
        - https://developers.worksmobile.com/jp/document/1005040?lang=en
    """
    print("init_rich_menu_first:get_init_status")

    extra = get_init_status("rich_menu")

    if extra is None:
        rich_menus = init_rich_menu(DEFAULT_LANG)
        insert_init_status("rich_menu", json.dumps(rich_menus))
    else:
        print("init_rich_menu_first:extra")
        rich_menus = json.loads(extra)

    if rich_menus is None:
        raise Exception("init rich menu failed. rich_menus is None")

    rich_menu_id = rich_menus.get(RICH_MENUS[DEFAULT_LANG]["name"], None)
    if rich_menu_id is None:
        raise Exception("init rich menu failed. rich_menu_id is None")

    print("init_rich_menu_first:global_data.set_value")
    global_data.set_value(DEFAULT_LANG, rich_menu_id)
def init_calendar_first():
    """
    Initialize calendar API.
    """
    calendar_id = get_init_status("calendar")
    if calendar_id is None:
        calendar_id = init_calendar()
        insert_init_status("calendar", calendar_id)

    global_data.set_value(API_BO["calendar"]["name"], calendar_id)
def check_init_bot():
    """
    Initialize bot no, check if the bot is initialized.
    If this function gets an exception, it is probably like script/registerBot.py.
    This is not executed or the execution failed.

        reference
        - https://developers.worksmobile.com/jp/document/3005001?lang=en
    """
    extra = get_init_status("bot_no")
    if extra is None:
        raise Exception("bot no init failed.")
    global_data.set_value("bot_no", extra)
def init_rich_menu_first():
    """
    Initialize rich menu API. Check also: attendance_management_bot/externals/richmenu.py

        reference
        - https://developers.worksmobile.com/jp/document/1005040?lang=en
    """
    rich_menu_id = get_init_status("rich_menu")

    if rich_menu_id is None:
        rich_menu_id = init_rich_menu()
        insert_init_status("rich_menu", rich_menu_id)

    if rich_menu_id is None:
        raise Exception("init rich menu failed.")
    global_data.set_value("rich_menu", rich_menu_id)
def init_bot():
    """
    Initialize bot info. If the BOT is not registered, the system will fail to start.

    Before BOT registration,
    the system_init_status table will be queried.
    If BOT has been registered, it does not need to be re registered.
    Otherwise, the bot will be saved in the system init status table after success,
    indicating that the registration of BOT has been completed during initialization.
    """

    bot_no = get_init_status("bot_no")
    if bot_no is not None:
        print("bot no has created. bot_no:%s" % (bot_no, ))
        return

    bot_no = register_bot(PHOTO_URL)
    register_bot_domain(bot_no)
    print("photo:%s" % (PHOTO_URL, ))
    print("callback:%s" % (CALLBACK_ADDRESS, ))
    if bot_no is not None:
        insert_init_status("bot_no", bot_no)