コード例 #1
0
        /// <summary>
        /// 初始化各组件
        /// </summary>
        /// <param name="_config"></param>
        /// <param name="_minfo"></param>
        public void Init(Config _config, MiraiInfo _minfo)
        {
            minfo  = _minfo;
            config = _config;

            money = new MoneyManager();
            money.init(config["money"], MoneyPath);


            if (config["historySave"] == "1")
            {
                // 打开历史记录,不会是真的吧
                HistoryPath = Path.GetFullPath(config["historyPath"]);
                if (!Directory.Exists(HistoryPath))
                {
                    Directory.CreateDirectory(HistoryPath);
                }
                processOutput?.Invoke($"历史记录保存在 {HistoryPath} 里");
                history.init(HistoryPath);
            }
            else
            {
                processOutput?.Invoke($"历史记录不会有记录");
            }


            //LoadConfig();
            LoadMirai();

            LoadGroupAndFriendList();

            LoadPlugins();
        }
コード例 #2
0
ファイル: FormMonitor.cs プロジェクト: hontsev/MIraiKUgua
        /// <summary>
        /// 检查并初始化配置
        /// </summary>
        /// <returns></returns>
        bool checkAndSetConfigValid()
        {
            try
            {
                if (config == null)
                {
                    return(false);
                }

                if (string.IsNullOrWhiteSpace(config["version"]))
                {
                    config["version"] = "v0.0.1";
                }
                if (string.IsNullOrWhiteSpace(config["debug"]))
                {
                    config["debug"] = "0";
                }

                // qq info
                if (string.IsNullOrWhiteSpace(config["qq"]))
                {
                    config["qq"] = "00000";
                }
                if (string.IsNullOrWhiteSpace(config["passwd"]))
                {
                    config["passwd"] = "nopasswd";
                }

                // mirai config
                if (string.IsNullOrWhiteSpace(config["host"]))
                {
                    config["host"] = "127.0.0.1";
                }
                if (string.IsNullOrWhiteSpace(config["port"]))
                {
                    config["port"] = "9999";
                }
                //if (string.IsNullOrWhiteSpace(config["key"])) config["key"] = "null";
                miraiInfo         = new MiraiInfo();
                miraiInfo.authKey = miraiKey;
                miraiInfo.port    = int.Parse(config["port"]);
                miraiInfo.host    = config["host"];
                refreshMiraiHttpPluginYml();

                beginTime           = DateTime.Now;
                config["starttime"] = beginTime.ToString("G");
                if (string.IsNullOrWhiteSpace(config["historySave"]))
                {
                    config["historySave"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["historyPath"]))
                {
                    config["historyPath"] = "./history/";
                }
                if (string.IsNullOrWhiteSpace(config["startnum"]))
                {
                    config["startnum"] = "0";
                }
                config.setInt("startnum", config.getInt("startnum") + 1);
                if (string.IsNullOrWhiteSpace(config["playtimeprivate"]))
                {
                    config["playtimeprivate"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["playtimegroup"]))
                {
                    config["playtimegroup"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["errtime"]))
                {
                    config["errtime"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["askname"]))
                {
                    config["askname"] = ".";
                }
                if (string.IsNullOrWhiteSpace(config["money"]))
                {
                    config["money"] = "比特币";
                }
                if (string.IsNullOrWhiteSpace(config["ignoreall"]))
                {
                    config["ignoreall"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["testonly"]))
                {
                    config["testonly"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["master"]))
                {
                    config["master"] = "0";
                }
                if (string.IsNullOrWhiteSpace(config["groupmsgbuff"]))
                {
                    config["groupmsgbuff"] = "0";
                }
            }
            catch (Exception ex)
            {
                FileHelper.Log(ex);
                return(false);
            }

            return(true);
        }