示例#1
0
def increase_counter(
    name: Any = "",
    report_to_lean_cloud=False,
    report_to_google_analytics=True,
    ga_type=ga.GA_REPORT_TYPE_EVENT,
    ga_category="",
    ga_misc_params: dict = None,
):
    name = str(name)

    if name == "":
        raise AssertionError("increase_counter name not set")

    def _cb():
        if report_to_lean_cloud and is_daily_first_run(name):
            # lean_cloud的计数器每日最多上报一次
            increase_counter_sync_lean_cloud(name)

        if report_to_google_analytics:
            increase_counter_sync_google_analytics(name, ga_type, ga_category,
                                                   ga_misc_params)

        # UNDONE: 增加自建的计数器上报

    async_call(_cb)
示例#2
0
def show_update_info_on_first_run(ui: UpdateInfo):
    if now_version == ui.latest_version and is_first_run(
            f"update_version_v{ui.latest_version}") and not use_by_myself():
        message = (
            f"新版本v{ui.latest_version}已更新完毕,并成功完成首次运行。本次具体更新内容展示如下,以供参考:\n"
            f"{ui.update_message}")

        def cb():
            win32api.MessageBox(0, message, "更新", win32con.MB_OK)

        async_call(cb)
示例#3
0
def main():
    increase_counter(name="run/begin", ga_type=ga.GA_REPORT_TYPE_PAGE_VIEW)

    prepare_env()

    # 启动时检查是否需要同步本机数据目录备份的旧版本配置
    try_load_old_version_configs_from_user_data_dir()

    change_title()

    print_update_message_on_first_run_new_version()

    logger.warning(
        f"开始运行DNF蚊子腿小助手,ver={now_version} {ver_time},powered by {author}")
    logger.warning(
        color("fg_bold_cyan") +
        "如果觉得我的小工具对你有所帮助,想要支持一下我的话,可以帮忙宣传一下或打开付费指引/支持一下.png,扫码打赏哦~")

    # 读取配置信息
    load_config("config.toml", "config.toml.local")
    cfg = config()

    if len(cfg.account_configs) == 0:
        raise Exception("未找到有效的账号配置,请检查是否正确配置。ps:多账号版本配置与旧版本不匹配,请重新配置")

    notify_manual_check_update_on_release_too_long(cfg.common)

    check_proxy(cfg)

    try_report_usage_info(cfg)

    if cfg.common.disable_cmd_quick_edit:
        disable_quick_edit_mode()

    show_notices()

    if cfg.common.allow_only_one_instance:
        logger.info("当前仅允许单个实例运行,将尝试干掉其他实例~")
        async_call(kill_other_instance_on_start)
    else:
        logger.info("当前允许多个实例同时运行~")

    init_pool(cfg.get_pool_size())

    change_title(multiprocessing_pool_size=cfg.get_pool_size(),
                 enable_super_fast_mode=cfg.common.enable_super_fast_mode)

    show_multiprocessing_info(cfg)

    account_names = []
    for account_cfg in cfg.account_configs:
        account_names.append(account_cfg.name)

    logger.info(f"当前共配置{len(account_names)}个账号,具体如下:{account_names}")

    clean_dir_to_size(log_directory, cfg.common.max_logs_size * MiB,
                      cfg.common.keep_logs_size * MiB)
    clean_dir_to_size(f"utils/{log_directory}", cfg.common.max_logs_size * MiB,
                      cfg.common.keep_logs_size * MiB)

    show_ask_message_box(cfg)

    check_all_skey_and_pskey(cfg)

    check_djc_role_binding()

    # 确保道聚城绑定OK后在活动运行同时进行异步的弹窗提示
    check_first_run_async(cfg)

    # 挪到所有账号都登陆后再尝试自动更新,从而能够判定是否已购买DLC
    try_auto_update(cfg)

    # 检查是否有更新,用于提示未购买自动更新的朋友去手动更新~
    if cfg.common.check_update_on_start:
        check_update(cfg)

    # 查询付费信息供后面使用
    show_head_line("查询付费信息")
    logger.warning("开始查询付费信息,请稍候~")
    user_buy_info = get_user_buy_info(cfg.get_qq_accounts())
    show_buy_info(user_buy_info, cfg, need_show_message_box=False)

    sas(cfg, "启动时展示账号概览", user_buy_info)

    # 预先尝试创建和加入固定队伍,从而每周第一次操作的心悦任务也能加到队伍积分中
    try_join_xinyue_team(cfg, user_buy_info)

    # 正式进行流程
    run(cfg, user_buy_info)

    # 尝试领取心悦组队奖励
    try_take_xinyue_team_award(cfg, user_buy_info)

    # # 尝试派赛利亚出去打工
    # try_xinyue_sailiyam_start_work(cfg)

    # 活动开启关闭时调这个开关即可
    enable_card_lottery = False

    if enable_card_lottery:
        auto_send_cards(cfg)

    show_extra_infos(cfg)
    sas(cfg, "运行完毕展示账号概览", user_buy_info)

    if enable_card_lottery:
        show_lottery_status("卡片赠送完毕后展示各账号抽卡卡片以及各礼包剩余可领取信息",
                            cfg,
                            need_show_tips=True)

    show_pay_info(cfg)

    # 显示小助手的使用概览
    if cfg.common._show_usage:
        show_usage()

    # 运行结束展示下多进程信息
    show_multiprocessing_info(cfg)

    # 检查是否有更新,用于提示未购买自动更新的朋友去手动更新~
    if cfg.common.check_update_on_end:
        check_update(cfg)

    # 运行完毕备份配置到本机数据目录
    try_save_configs_to_user_data_dir()

    increase_counter(name="run/end", ga_type=ga.GA_REPORT_TYPE_PAGE_VIEW)

    show_head_line("运行完毕")