/// <summary> /// 初始化处理 /// </summary> internal static ValueTask Initalization(object sender, ConnectEventArgs connectEvent) { ConsoleLog.Info("AntiRain初始化", "与onebot客户端连接成功,初始化资源..."); //初始化配置文件 ConsoleLog.Info("AntiRain初始化", $"初始化用户[{connectEvent.LoginUid}]配置"); Config config = new Config(connectEvent.LoginUid); config.UserConfigFileInit(); config.LoadUserConfig(out UserConfig userConfig, false); //在控制台显示启用模块 ConsoleLog.Info("已启用的模块", $"\n{userConfig.ModuleSwitch}"); //显示代理信息 if (userConfig.ModuleSwitch.Hso && !string.IsNullOrEmpty(userConfig.HsoConfig.PximyProxy)) { ConsoleLog.Debug("Hso Proxy", userConfig.HsoConfig.PximyProxy); } //初始化数据库 DatabaseInit.Init(connectEvent); //初始化定时器线程 if (userConfig.ModuleSwitch.Bili_Subscription) { ConsoleLog.Debug("Timer Init", $"flash span = {userConfig.SubscriptionConfig.FlashTime}"); TimerEventParse.TimerAdd(connectEvent, userConfig.SubscriptionConfig.FlashTime); } return(ValueTask.CompletedTask); }
private static void LoadConfig() { ConfigurationHelper.Init(); RedisConnection.Init(ConfigurationHelper.GetInteger("Redis:Db"), ConfigurationHelper.GetString("Redis:Host"), ConfigurationHelper.GetInteger("Redis:Port"), ConfigurationHelper.GetString("Redis:PassWd")); BsonSerializer.RegisterSerializer(typeof(DateTime), new MyMongoDBDateTimeSerializer()); LogHelper.Init(ConfigurationHelper.GetString("Mongo:ConnectionString"), ConfigurationHelper.GetString("Mongo:DatabaseName"), ConfigurationHelper.GetBoolean("Mongo:IsReplicaSet"), ConfigurationHelper.GetString("Mongo:ReplicaSetName")); BaseProcs.Init(MongoConnect.GetHelper(ConfigurationHelper.GetString("Mongo:ConnectionString"), ConfigurationHelper.GetString("Mongo:DatabaseName"), 10, ConfigurationHelper.GetBoolean("Mongo:IsReplicaSet"), ConfigurationHelper.GetString("Mongo:ReplicaSetName"))).Wait(); DatabaseInit.Init(); //AccountProcs.Init(MongoConnect.GetHelper(ConfigurationHelper.GetString("AccountDb:ConnectionString"), ConfigurationHelper.GetString("AccountDb:DatabaseName"), 10, ConfigurationHelper.GetBoolean("AccountDb:IsReplicaSet"), ConfigurationHelper.GetString("AccountDb:ReplicaSetName"))).Wait(); CultureInfo.CurrentCulture = new CultureInfo("vi-VN"); }
public static void AppEnable(object sender, CQAppEnableEventArgs e) { try { //打开控制台 //ConsoleLog.AllocConsole(); Console.Title = @"SuiseiBot"; //初始化配置文件 Config config = new Config(e.CQApi.GetLoginQQ().Id); //数据库初始化 ConsoleLog.Info("初始化", "SuiseiBot初始化"); //设置Log等级 ConsoleLog.SetLogLevel(config.LoadedConfig.LogLevel); //读取应用信息 ConsoleLog.Debug("APP AuthCode(native plugin ID)", e.CQApi.AppInfo.AuthCode); //修改环境文件夹,初始化环境 ConsoleLog.Debug("获取到环境路径", Directory.GetCurrentDirectory()); Environment.SetEnvironmentVariable("Path", Directory.GetCurrentDirectory()); //显示Log等级 ConsoleLog.Debug("Log Level", config.LoadedConfig.LogLevel); //在控制台显示启用模块 ConsoleLog.Info("已启用的模块", $"\n{config.LoadedConfig.ModuleSwitch}"); DatabaseInit.Init(e); //将关键词和帮助文本写入内存 WholeMatchCmd.KeywordInit(); PCRGuildCmd.PCRGuildCommandInit(); GuildCommandHelp.InitHelpText(); KeywordCmd.SpecialKeywordsInit(e.CQApi); //初始化定时器线程 if (config.LoadedConfig.ModuleSwitch.Bili_Subscription || config.LoadedConfig.ModuleSwitch.PCR_Subscription) { timer = new TimerInit(e.CQApi, config.LoadedConfig.SubscriptionConfig.FlashTime); } e.Handler = true; } catch (Exception exception) { ConsoleLog.Error("error", ConsoleLog.ErrorLogBuilder(exception)); } }