/// <summary>
    /// Type=1003 应用被启用<para/>
    /// 处理 酷Q 的插件启动事件回调
    /// </summary>
    /// <param name="sender">事件的触发对象</param>
    /// <param name="e">事件的附加参数</param>
    public void AppEnable(object sender, CQAppEnableEventArgs e)
    {
        // 当应用被启用后,将收到此事件。
        // 如果酷Q载入时应用已被启用,则在_eventStartup(Type=1001,酷Q启动)被调用后,本函数也将被调用一次。
        // 如非必要,不建议在这里加载窗口。(可以添加菜单,让用户手动打开窗口)
        try
        {
            ApiModel.setModel(e.CQApi, e.CQLog);
            SQLiteManager.GetInstance();
            FileOptions.GetInstance();
            GuildBattle.InitFile();

            DirectoryInfo root    = new DirectoryInfo(e.CQApi.AppDirectory);
            FileInfo[]    files   = root.GetFiles();
            string        pattern = @"Data\-(\d+)\.ini";
            foreach (FileInfo info in files)
            {
                if (Regex.IsMatch(info.Name, pattern))
                {
                    Match temp = Regex.Match(info.Name, pattern);
                    GuildBattle.GetInstance(long.Parse(temp.Groups[1].Value));
                }
            }
        } catch (Exception exception)
        {
            e.CQLog.Warning("AppEnable", exception);
        }
    }
 /// <summary>
 /// Type=1003 应用被启用<para/>
 /// 处理 酷Q 的插件启动事件回调
 /// </summary>
 /// <param name="sender">事件的触发对象</param>
 /// <param name="e">事件的附加参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     // 当应用被启用后,将收到此事件。
     // 如果酷Q载入时应用已被启用,则在_eventStartup(Type=1001,酷Q启动)被调用后,本函数也将被调用一次。
     // 如非必要,不建议在这里加载窗口。(可以添加菜单,让用户手动打开窗口)
     MessageProcessInterface.startCheck();
 }
Exemple #3
0
 /// <summary>
 /// Type=1003 应用被启用<para/>
 /// 处理 酷Q 的插件启动事件回调
 /// </summary>
 /// <param name="sender">事件的触发对象</param>
 /// <param name="e">事件的附加参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     // 当应用被启用后,将收到此事件。
     // 如果酷Q载入时应用已被启用,则在_eventStartup(Type=1001,酷Q启动)被调用后,本函数也将被调用一次。
     // 如非必要,不建议在这里加载窗口。(可以添加菜单,让用户手动打开窗口)
     TimeCheck.AppStart(e.CQApi, e.CQLog);
 }
Exemple #4
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     if (!sqliteHelper.HasConfig(e.CQApi.AppDirectory))
     {
         sqliteHelper.CreateConfig(e.CQApi.AppDirectory);
     }
 }
Exemple #5
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     if (File.Exists(e.CQApi.AppDirectory + "data.db") == false)
     {
         File.WriteAllBytes(e.CQApi.AppDirectory + "data.db", Properties.Resources.data);
     }
     PoemData.Init();
 }
 /// <summary>
 /// Type=1003 应用被启用<para/>
 /// 处理 酷Q 的插件启动事件回调
 /// </summary>
 /// <param name="sender">事件的触发对象</param>
 /// <param name="e">事件的附加参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     // 当应用被启用后,将收到此事件。
     // 如果酷Q载入时应用已被启用,则在_eventStartup(Type=1001,酷Q启动)被调用后,本函数也将被调用一次。
     // 如非必要,不建议在这里加载窗口。(可以添加菜单,让用户手动打开窗口)
     ApiModel.setModel(e.CQApi, e.CQLog);
     MessageCount.GetInstance();
 }
Exemple #7
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="e">CQAppEnableEventArgs</param>
        public static void Init(CQAppEnableEventArgs e)
        {
            string DBPath = SugarUtils.GetDBPath(e.CQApi.GetLoginQQ().Id.ToString());

            ConsoleLog.Debug("IO", $"获取数据路径{DBPath}");
            if (!File.Exists(DBPath))//查找数据文件
            {
                //数据库文件不存在,新建数据库
                ConsoleLog.Warning("数据库初始化", "未找到数据库文件,创建新的数据库");
                Directory.CreateDirectory(Path.GetPathRoot(DBPath));
                File.Create(DBPath).Close();
            }
            SqlSugarClient dbClient = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString      = $"DATA SOURCE={DBPath}",
                DbType                = DbType.Sqlite,
                IsAutoCloseConnection = true,
                InitKeyType           = InitKeyType.Attribute
            });

            try
            {
                if (!SugarUtils.TableExists <SuiseiData>(dbClient)) //彗酱数据库初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到慧酱数据表 - 创建一个新表");
                    SugarUtils.CreateTable <SuiseiData>(dbClient);
                }
                if (!SugarUtils.TableExists <MemberInfo>(dbClient)) //成员状态表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到成员状态表 - 创建一个新表");
                    SugarUtils.CreateTable <MemberInfo>(dbClient);
                }
                if (!SugarUtils.TableExists <BiliSubscription>(dbClient)) //动态记录表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到动态记录表 - 创建一个新表");
                    SugarUtils.CreateTable <BiliSubscription>(dbClient);
                }
                if (!SugarUtils.TableExists <GuildBattleBoss>(dbClient)) //会战数据表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到会战数据表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildBattleBoss>(dbClient);
                    //写入初始化数据
                    dbClient.Insertable(GuildBattleBoss.GetInitBossInfos()).ExecuteCommand();
                }
                if (!SugarUtils.TableExists <GuildInfo>(dbClient)) //会战状态表的初始化
                {
                    ConsoleLog.Warning("数据库初始化", "未找到会战状态表 - 创建一个新表");
                    SugarUtils.CreateTable <GuildInfo>(dbClient);
                }
            }
            catch (Exception exception)
            {
                ConsoleLog.Fatal("数据库初始化错误", ConsoleLog.ErrorLogBuilder(exception));
                Thread.Sleep(5000);
                throw;
            }
        }
Exemple #8
0
 public static int Event_eventEnable()
 {
     if (Event_eventEnableHandler != null)
     {
         CQAppEnableEventArgs args = new CQAppEnableEventArgs(cqApi, cqLog, 1003, 1003, "AppEnableInterface", "_eventEnable", 30000);
         Event_eventEnableHandler(typeof(EventExport), args);
     }
     return(0);
 }
Exemple #9
0
 public static int Event_eventEnable()
 {
     if (Event_eventEnableHandler != null)
     {
         CQAppEnableEventArgs args = new CQAppEnableEventArgs(AppData.CQApi, AppData.CQLog, 1003, 1003, "应用已被启用", "_eventEnable", 30000);
         Event_eventEnableHandler(typeof(CQEventExport), args);
     }
     return(0);
 }
Exemple #10
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     try
     {
         Common.CQApi = e.CQApi;
         Common.CQLog = e.CQLog;
         Common.ae    = e;
     }catch (Exception ex)
     {
         e.CQLog.Warning("获取common失败" + ex.Message);
     }
 }
Exemple #11
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            if (CQApi == null)
            {
                CQApi = e.CQApi;
            }

            t.Elapsed  += new System.Timers.ElapsedEventHandler(getNewChapter);
            t.AutoReset = true; //每到指定时间Elapsed事件是触发一次(false),还是一直触发(true)
            t.Enabled   = true;
            t.Start();
        }
Exemple #12
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            ConfigHandler.loadConfig(e);

            String dbFile = e.CQApi.AppDirectory + "com.metricv.pcrguild.db";

            e.CQLog.Info("行会战排刀器", "正在加载...");

            DBManager.up(e);
            DBManager.addManager();

            e.CQLog.Info("行会战排刀器", "加载完成");
        }
Exemple #13
0
        /// <summary>
        /// 初始化数据库
        /// </summary>
        /// <param name="e">CQAppEnableEventArgs</param>
        public static void Init(CQAppEnableEventArgs e)
        {
            string DBPath = SugarUtils.GetDBPath(e.CQApi.GetLoginQQ().Id.ToString());

            ConsoleLog.Info("IO", $"获取数据路径{DBPath}");
            if (!File.Exists(DBPath))//查找数据文件
            {
                //数据库文件不存在,新建数据库
                ConsoleLog.Warning("数据库初始化", "未找到数据库文件,创建新的数据库");
                Directory.CreateDirectory(Path.GetPathRoot(DBPath));
                File.Create(DBPath).Close();
            }
            SqlSugarClient dbClient = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString      = $"DATA SOURCE={DBPath}",
                DbType                = DbType.Sqlite,
                IsAutoCloseConnection = true,
                InitKeyType           = InitKeyType.Attribute
            });

            if (!SugarUtils.TableExists <SuiseiData>(dbClient)) //彗酱数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到慧酱数据表 - 创建一个新表");
                SugarUtils.CreateTable <SuiseiData>(dbClient);
            }
            if (!SugarUtils.TableExists <GuildData>(dbClient)) //公会数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到公会表数据表 - 创建一个新表");
                SugarUtils.CreateTable <GuildData>(dbClient);
            }
            if (!SugarUtils.TableExists <MemberData>(dbClient)) //公会成员数据库初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到成员表数据表 - 创建一个新表");
                SugarUtils.CreateTable <MemberData>(dbClient);
            }
            if (!SugarUtils.TableExists <MemberStatus>(dbClient))//成员状态表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到成员状态表 - 创建一个新表");
                SugarUtils.CreateTable <MemberStatus>(dbClient);
            }
            if (!SugarUtils.TableExists <BossInfo>(dbClient))//Boss信息表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到Boss信息表 - 创建一个新表");
                SugarUtils.CreateTable <BossInfo>(dbClient);
            }
            if (!SugarUtils.TableExists <BiliSubscription>(dbClient)) //动态记录表的初始化
            {
                ConsoleLog.Warning("数据库初始化", "未找到动态记录表 - 创建一个新表");
                SugarUtils.CreateTable <BiliSubscription>(dbClient);
            }
        }
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            e.CQLog.Info("信息", "欢迎使用!");

            var dataDir    = e.CQApi.AppDirectory;
            var configPath = dataDir + "/config.json";

            ConfigWorker.Load(configPath);

            CoolRepeater.Api = e.CQApi;

            ConfigWorker.Save(ConfigWorker.Path);

            e.CQLog.Info("信息", "配置文件加载完成。");
        }
Exemple #15
0
        public void OnLoad(object obj, CQAppEnableEventArgs e)
        {
            List <GroupInfo> groups = e.CQApi.GetGroupList().ToList();

            foreach (GroupInfo group in groups)
            {
                if (groupList.ContainsKey(group.Group.Id))
                {
                    continue;
                }
                groupList.Add(group.Group.Id, new Info {
                    isCoolingDown = false, lastMsg = ""
                });
            }
        }
Exemple #16
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            AppData.CQLog.Info("欢迎使用!");
            AppData.CQLog.Info("正在加载配置文件和数据文件。");

            try
            {
                WhatDidToday.LoadConfig(AppData.CQApi.AppDirectory);
                WhatDidToday.LoadData(AppData.CQApi.AppDirectory);
            }
            catch (Exception ex)
            {
                AppData.CQLog.Fatal(ex.ToString());
                throw;
            }
        }
        //这个方法将在程序运行时执行
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            e.CQLog.Info("初始化", "WelcomeMessage插件加载...");
            Sdata.ISready    = false;
            Sdata.MessageMap = new Hashtable();
            Sdata.APIII      = e.CQApi;
            Sdata.log        = e.CQLog;

            //加载配置文件
            if (!File.Exists("./WelcomeMessage.txt"))
            {
                Sdata.log.Warning("初始化", "未找到配置文件,创建之...");
                File.Create("./WelcomeMessage.txt").Dispose();
                System.IO.StreamWriter config_file_ = new System.IO.StreamWriter("./WelcomeMessage.txt");
                config_file_.WriteLine("#修改为群号和对应的欢迎信息");
                config_file_.WriteLine("#例如:");
                config_file_.WriteLine("123456789 = 欢迎进群!");
                config_file_.Close();
                Sdata.log.Warning("初始化", "配置文件创建完毕,请修改配置文件并重新启用应用!");
                return;
            }

            //读取配置文件
            System.IO.StreamReader config_file = new System.IO.StreamReader("./WelcomeMessage.txt");
            while (true)
            {
                string line_text = config_file.ReadLine();
                if (line_text == null)
                {
                    break;
                }
                if (line_text.StartsWith("#"))
                {
                    continue;
                }
                string[] temp1      = line_text.Split('=');
                String   qqGroup    = temp1[0].Trim();
                String   temp2      = line_text.Substring(line_text.IndexOf("=") + 1);
                String   WelcomeMsg = temp2.Trim();
                Sdata.log.Info("初始化", "配置项目{QQ=" + qqGroup + ";msg=" + WelcomeMsg + "}");
                Sdata.MessageMap.Add(qqGroup, WelcomeMsg);
            }
            config_file.Close();

            Sdata.ISready = true;
        }
 /// <summary>
 /// APP启用
 /// </summary>
 /// <param name="sender">事件来源</param>
 /// <param name="e">事件参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     try
     {
         Data.E = e;
         Operation.Setup();
         Operation.AddLog("插件启动成功!\nCQ插件作者:gxh\nSDK:Native.Sdk\n编写语言C#\n需配合BDX端的Websocket插件使用!");
         Operation.AddLog($"当前{Data.WSClients.Count}个Websocket实例");
         for (int i = 0; i < Data.WSClients.Count; i++)
         {
             Operation.AddLog($"编号{i+1}状态:{(Data.WSClients.Keys.ElementAt(i).IsAlive ? "已连接" : "离线")}");
         }
     }
     catch (Exception err)
     {
         Operation.AddLog("启动失败请重试!!!\n" + err.ToString());
     }
 }
        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));
            }
        }
Exemple #20
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            e.CQLog.Info("[Ruby]", "应用开启");


            //启用数据库
            Common.Conn = new SQLiteConnection(@"data source=data.db");
            Common.Conn.Open();
            //初始化等级系统
            Common.Levels = new List <common.Level> {
                //new common.Level(-2,"底灵境",-500,"从未有人到过的天堂",100,0),
                //new common.Level(-1,"克灵境",-100,"向死而生",100,0),
                new common.Level(0, "凡人境", 0, "普通", 100, 0),
                new common.Level(1, "入灵境", 333, "初窥门槛", 100, 0),
                new common.Level(2, "虚灵境", 666, "力量涌动", 100, 0),
                new common.Level(3, "乞灵境", 999, "乞灵之下,皆为凡人", 40, -100),
                new common.Level(4, "唤灵境", 1999, "水木草石,始知形意", 71, -500),
                new common.Level(5, "通灵境", 3599, "通天灵力,移山填海", 44, -777),

                new common.Level(6, "问灵境", 6000, "探幽寻微,法力无边", 69, -560),
                new common.Level(7, "寻灵境", 10000, "寻天问道,初登大堂", 25, -314),
                new common.Level(8, "叩灵境", 15000, "道前一叩,生死由天", 20, -324),
                new common.Level(9, "化灵境", 30000, "灵气化体,身融天地", 15, -2000),
                new common.Level(10, "地灵境", 60000, "天地有灵,由谁执掌", 10, -9999),

                new common.Level(11, "天灵境", 120000, "天地有灵,吾执掌之", 5, -9999),
                new common.Level(12, "仙境", 240000, "仙人抚顶,羽化飞升", 0, -4444),

                new common.Level(100, "不可能", 100000000, "不可能", 71, -500)
            };
            e.CQLog.Info("[Ruby]", "数据库加载成功");
            Game.Init();
            e.CQLog.Info("[Ruby]", "玩家以及游戏加载成功");
            //读取夸群主的词语

            //StreamReader reader = new StreamReader(@"good.txt", Encoding.GetEncoding("utf-8"));
            //Common.Word = reader.ReadToEnd().Replace("\r\n","\n").Split('\n');
            //e.CQLog.Info("[Ruby]", "读取成功");

            //reader.Close();
        }
        //这个方法将在程序运行时执行
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            e.CQLog.Info("localnet连接插件开始加载...");
            Sdata.APIII = e.CQApi;
            Sdata.log   = e.CQLog;

            //加载配置文件
            if (!File.Exists("./LNconfig.txt"))
            {
                Sdata.log.Warning("配置文件", "未找到配置文件,创建之...");
                File.Create("./LNconfig.txt").Dispose();
                System.IO.StreamWriter config_file_ = new System.IO.StreamWriter("./LNconfig.txt");
                config_file_.WriteLine("#修改为你localnet的IP和端口");
                config_file_.WriteLine("IP=127.0.0.1");
                config_file_.WriteLine("Port=2333333");
                config_file_.WriteLine("#管理员QQ号");
                config_file_.WriteLine("adminQQ=123456789");
                config_file_.Close();
                Sdata.log.Warning("配置文件", "配置文件创建完毕,请修改配置文件并重新启用应用");
                return;
            }


            if (!File.Exists("./LNid.txt"))
            {
                Sdata.log.Warning("配置文件", "未找到ID配置文件,创建之...");
                File.Create("./LNid.txt").Dispose();
                Sdata.log.Warning("配置文件", "ID配置文件创建完毕");
            }

            //读取配置文件
            System.IO.StreamReader config_file = new System.IO.StreamReader("./LNconfig.txt");
            while (true)
            {
                string line_text = config_file.ReadLine();
                if (line_text == null)
                {
                    break;
                }
                string[] temp2 = line_text.Split('=');
                if (temp2.Length != 2)
                {
                    continue;
                }
                switch (temp2[0])
                {
                case "IP":
                    Sdata.lnIP = temp2[1];
                    break;

                case "Port":
                    Sdata.lnPort = int.Parse(temp2[1]);
                    break;

                case "adminQQ":
                    Sdata.adminQQ = temp2[1];
                    break;

                default:
                    Sdata.log.Info("配置文件", "未知配置项目:" + line_text);
                    break;
                }
            }
            config_file.Close();
            if (Sdata.lnIP == null)
            {
                Sdata.log.Error("配置文件", "未在配置文件中找到配置项目<IP>"); return;
            }
            if (Sdata.lnPort == null)
            {
                Sdata.log.Error("配置文件", "未在配置文件中找到配置项目<Port>"); return;
            }
            if (Sdata.adminQQ == null)
            {
                Sdata.log.Error("配置文件", "未在配置文件中找到配置项目<adminQQ>"); return;
            }

            //读取ID对照表
            System.IO.StreamReader id_file = new System.IO.StreamReader("./LNid.txt");
            while (true)
            {
                string line_text = id_file.ReadLine();
                if (line_text == null)
                {
                    break;
                }
                string[] temp2 = line_text.Split('=');
                if (temp2.Length != 2)
                {
                    Sdata.log.Error("配置文件", "ID配置文件行<" + line_text + ">无效"); continue;
                }
                Sdata.IDlist.Add(temp2[0], temp2[1]);
            }

            //载入群列表
            List <Native.Sdk.Cqp.Model.GroupInfo> temp1 = Sdata.APIII.GetGroupList();

            for (int temp2 = 0; temp2 < temp1.Count; temp2++)//批量向localnet注册群
            {
                Sdata.log.Info("初始化", "加载群:" + temp1[temp2].Group.Id + "=" + KQlib.ID_re(temp1[temp2].Group.Id.ToString()));
                Sdata.GroupList.Add(temp1[temp2].Group.Id, new TCPLK_QQ(Sdata.lnIP, Sdata.lnPort, KQlib.ID_re(temp1[temp2].Group.Id.ToString()), temp1[temp2].Group.Id));
            }
            Sdata.isReady = true;
        }
Exemple #22
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     Utils.Initial();
     LuaEnv.LuaStates.Run("main", "AppEnable", new { });
 }
Exemple #23
0
 /// <summary>
 /// 酷Q应用启用 回调
 /// </summary>
 /// <param name="sender">事件来源对象</param>
 /// <param name="e">附加的事件参数</param>
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     Common.CQApi = e.CQApi;
     Common.CQLog = e.CQLog;
     TheTimer.Countdown1();
 }
Exemple #24
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     Event_GroupMessage.GroupList = new Hashtable();
 }
Exemple #25
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     GeneralControl.CQApi = e.CQApi;
     GeneralControl.CQLog = e.CQLog;
     Init init = new Init();
 }
Exemple #26
0
        public void AppEnable(object sender, CQAppEnableEventArgs e)
        {
            #region  出CQApi与CQLog供外部调用
            CQ.Api                      = e.CQApi;
            CQ.Log                      = e.CQLog;
            Eas.CQ.Api                  = e.CQApi;
            Eas.CQ.Log                  = e.CQLog;
            Schedule.CQ.Api             = e.CQApi;
            Schedule.CQ.Log             = e.CQLog;
            GithubWatcher.Shared.CQ.Api = e.CQApi;
            GithubWatcher.Shared.CQ.Log = e.CQLog;
            CosOperation.CQ.Api         = e.CQApi;
            CosOperation.CQ.Log         = e.CQLog;
            CourseFunction.CQ.Api       = e.CQApi;
            CourseFunction.CQ.Log       = e.CQLog;
            #endregion

            try
            {
                #region 基础文件初始化
                IF.InitFiles(Environment.CurrentDirectory, "dc.dll", "验证码识别组件");
                IF.InitFiles(Environment.CurrentDirectory, "SQLite.Interop.dll", "SQLite组件");
                IF.InitFiles(e.CQApi.AppDirectory, "jwxt.db", "教务系统数据库文件");
                if (ini.Read(e.CQApi.AppDirectory + @"\配置.ini", "重初始化", "日程", "") == "真")
                {
                    IF.InitFiles(e.CQApi.AppDirectory, "ScheduleDB.db", "日程数据库文件", true);
                    ini.Write(e.CQApi.AppDirectory + @"\配置.ini", "重初始化", "日程", "");
                    e.CQLog.Warning("初始化", "日程数据库文件重初始化完成");
                }
                else
                {
                    IF.InitFiles(e.CQApi.AppDirectory, "ScheduleDB.db", "日程数据库文件");
                }
                IF.InitFiles(e.CQApi.AppDirectory, "GithubWatcher.db", "Git数据库文件");
                IF.InitFiles(e.CQApi.AppDirectory, "Attentions.db", "关注数据库文件");
                IF.InitFiles(e.CQApi.AppDirectory, "FirstWeekDate.ini", "周起始日期文件", true);

                #endregion

                #region 数据库与EF框架初始化
                Eas.InitializeDB.Init();
                Schedule.InitializeDB.Init();
                GithubWatcher.Models.InitializeDB.Init();
                AttentionSpace.InitializeDB.Init();
                #endregion

                #region 启动GithubWatcher Web服务
                var githubWatcherUrl = "http://localhost:44395/";   // run commend: ngrok http -host-header=localhost 44395     120.77.154.219:330
                WebApp.Start <Startup>(url: githubWatcherUrl);

                #endregion

                #region 启动Schedule线程
                Thread GsrTh = new Thread(Schedule.ScheduleThread.GroupScheduleRemind);
                GsrTh.Start();
                Thread PsrTh = new Thread(Schedule.ScheduleThread.PrivateScheduleRemind);
                PsrTh.Start();
                #endregion


                Common.CommandRouter = new CommandRouter.CommandRouter();
                RegisterCommand();

                e.CQLog.InfoSuccess("初始化", "插件初始化成功。");
                Common.IsInitialized = true;
            }
            catch (Exception ex)
            {
                Common.IsInitialized = false;
                e.CQLog.Error("初始化", "插件初始化失败,建议重启再试。错误信息:" + ex.GetType().ToString() + " " + ex.Message + "\n" + ex.StackTrace);
            }
        }
Exemple #27
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     return;
     //throw new NotImplementedException();
 }
Exemple #28
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     Main.Initialize(e.CQLog);
     OnAppEnable?.Invoke(sender, e);
 }
Exemple #29
0
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
 }
 public void AppEnable(object sender, CQAppEnableEventArgs e)
 {
     Global.Initialize(e.CQApi.AppDirectory);
     Chat.Api    = e.CQApi;
     Chat.SelfId = e.CQApi.GetLoginQQId();
 }