Exemplo n.º 1
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var releaseData = ReleaseGetter.Get();
                var ver         = new Version(releaseData.tag_name).Build;
                if (ver != localVersion)
                {
                    if (updating)
                    {
                        return;
                    }
                    updating = true;

                    Messenger.SendDebugInfo($"开始自动更新。当前版本为v{localVersion}, 将会更新到v{ver}");
                    Messenger.Broadcast($"机器人开始了自动更新, 大约在1分钟内机器人不会回答你的问题.");
                    AutoUpdateRR.Execute();
                    Thread.Sleep(1000);
                }
            }
            catch (WebException)
            {
                // 忽略
            }
            catch (Exception exception)
            {
                Messenger.SendDebugInfo(exception.ToString());
            }
        }
Exemplo n.º 2
0
        private void Timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (HotUpdateInfo.PreviousVersion)
            {
                return;
            }

            try
            {
                if (Config.Instance.UpdateLexion)
                {
                    WFResource.UpdateLexion();
                }
                var releaseData = ReleaseGetter.Get();
                var ver         = new Version(releaseData.tag_name).Build;
                if (ver != localVersion)
                {
                    if (updating)
                    {
                        return;
                    }
                    if (Config.Instance.AutoUpdate)
                    {
                        updating = true;

                        Messenger.SendDebugInfo($"开始自动更新。当前版本为v{localVersion}, 将会更新到v{ver}");
                        Messenger.Broadcast($"WFBot开始了自动更新, 当前版本为v{localVersion}, 将会更新到v{ver}, 大约在1分钟内机器人不会回答你的问题.");
                        AutoUpdateRR.Execute();
                        Thread.Sleep(1000);
                    }
                    else
                    {
                        if (!IsNotified)
                        {
                            IsNotified = true;
                            Messenger.SendDebugInfo($"→ WFBot插件本体{ver}版本发布了, 不考虑体验一下新Feature(Bug)?");
                        }
                    }
                }
            }
            catch (WebException)
            {
                // 忽略
            }
            catch (Exception exception)
            {
                Messenger.SendDebugInfo(exception.ToString());
            }
        }
Exemplo n.º 3
0
        private void Update(Desk desk)
        {
            const string path     = "Origind.Card.Game\\CardSharp.dll";
            const string filename = "CardSharp.dll";

            try
            {
                File.Delete(path);
            }
            catch (Exception e)
            {
                desk.AddMessage($"删除文件时发生错误 {e}");
                return;
            }
            var data = ReleaseGetter.Get();
            var wc   = new WebClient();

            wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36");
            wc.DownloadFile(data.assets.First(asset => asset.name == filename).browser_download_url, path);
            desk.AddMessage($"文件下载完成.");
        }
Exemplo n.º 4
0
        public InitEvent1()
        {
            onlineBuild = nameof(InitEvent1).Contains("_"); // trick
            if (onlineBuild)
            {
                localVersion = int.Parse(nameof(InitEvent1).Split(new[] { "_" }, StringSplitOptions.None)[1]);
                var delay = string.IsNullOrWhiteSpace(Config.Instance.GitHubOAuthKey) ? 60 : 600;
                var timer = new Timer(TimeSpan.FromSeconds(delay).TotalMilliseconds);
                timer1         = timer;
                timer.Elapsed += Timer_Elapsed;
                timer.Start();
            }
            else
            {
                var releaseData = ReleaseGetter.Get();
                var ver         = new Version(releaseData.tag_name).Build;
                Messenger.SendDebugInfo($"→ WFBot插件最新官方{ver}版本, 不去看看你错过了什么新Feature(Bug)?");
            }

            if (Config.Instance.IsPublicBot)
            {
                websocket = new WebSocketHandler();
            }
        }
Exemplo n.º 5
0
        private void LatestUpdate(Desk desk)
        {
            var data = ReleaseGetter.Get();

            desk.AddMessage($"更新时间为: {data.assets.First().updated_at}");
        }