Ejemplo n.º 1
0
 public static async void MoChangeLogs(SoraMessage e, string type)
 {
     try
     {
         var articles = new ArticleList(type);
         if (articles.Articles.Count > 0)
         {
             await e.Reply(new StringBuilder()
                           .AppendLine(articles.Title)
                           .Append(string.Join(Environment.NewLine,
                                               articles.Articles.Select(x => x.Key + Environment.NewLine + "    " + x.Value).Take(5)))
                           .ToString());
         }
         else
         {
             await e.ReplyToOriginal("无效的类型 (仅支持 beta/release/snapshot)");
         }
     }
     catch (Exception ex)
     {
         await e.ReplyToOriginal(new StringBuilder()
                                 .AppendLine("获取文章列表时发生错误")
                                 .Append(ex.GetFormatString()));
     }
 }
Ejemplo n.º 2
0
        public static async void FHL(SoraMessage e, string _char)
        {
            _char = SoraMessage.Escape(_char);
            if (_char.Length != 1)
            {
                await e.ReplyToOriginal("参数错误,请检查后重试");

                return;
            }
            var result = await Tools.Poem.Search(_char);

            if (result.Count <= 0)
            {
                await e.ReplyToOriginal("没有搜索到任何结果,请检查后重试");

                return;
            }
            if (result.Count <= 5)
            {
                await e.Reply($"带有「{_char}」字的诗句有:" + Environment.NewLine + string.Join(Environment.NewLine, result));
            }
            else
            {
                var s    = new string[5];
                var rand = new Tools.Rand();
                for (var i = 0; i < 5; i++)
                {
                    var id = rand.Int(1, result.Count) - 1;
                    s[i] = result[id];
                    result.RemoveAt(id);
                }
                await e.Reply($"带有「{_char}」字的诗句有(随机选取5句):" + Environment.NewLine + string.Join(Environment.NewLine, s));
            }
            await e.RemoveCoins(2);
        }
Ejemplo n.º 3
0
        public static async void MoChangeLogsFormat(SoraMessage e, string url)
        {
            url = SoraMessage.Escape(url);
            if (!url.StartsWith("https://feedback.minecraft.net/hc/en-us/articles/"))
            {
                await e.ReplyToOriginal("无效的目标文章网址");

                return;
            }
            try
            {
                var article = new Article(url);
                if (string.IsNullOrWhiteSpace(article.Title))
                {
                    await e.ReplyToOriginal("无效的目标文章网址");

                    return;
                }
                var bin = UbuntuPastebin.Paste(article.Markdown, "md", "Mojang");
                await e.ReplyToOriginal(new StringBuilder()
                                        .AppendLine("目标文章已格式化至以下地址暂存,请及时查阅以免数据过期")
                                        .Append(bin).ToString());
            }
            catch (Exception ex)
            {
                await e.ReplyToOriginal(new StringBuilder()
                                        .AppendLine("获取文章时发生错误")
                                        .Append(ex.GetFormatString()));
            }
        }
Ejemplo n.º 4
0
        public static async void Translate(SoraMessage e, string text)
        {
            text = SoraMessage.Escape(text);
            try
            {
                var result = BaiduTranslate.GetTranslateResult(text);
                if (result.Success)
                {
                    if (result.OriginalLanguage.Equals(result.TranslateLanguage))
                    {
                        await Task.Delay(1000);

                        result = BaiduTranslate.GetTranslateResult(text, result.OriginalLanguage?.Id ?? "zh", "en");
                    }
                    if (result.Success)
                    {
                        await e.ReplyToOriginal(new StringBuilder()
                                                .AppendLine($"[{result.OriginalLanguage}=>{result.TranslateLanguage}]")
                                                .Append(result.TranslateString).ToString());

                        return;
                    }
                }
                await e.ReplyToOriginal(new StringBuilder().Append("翻译失败,")
                                        .AppendLine(result.Info).Append(result.TipMessage).ToString());
            }
            catch (Exception ex)
            {
                await e.ReplyToOriginal(new StringBuilder().Append("翻译失败,")
                                        .AppendLine(ex.GetFormatString()).ToString());
            }
        }
Ejemplo n.º 5
0
        public static async void AddTip(SoraMessage e, DateTime time, string message)
        {
            message = SoraMessage.Escape(message);
            var now = DateTime.Now;

            if (time < now)
            {
                await e.ReplyToOriginal("提示时间不可设置为过去的时间");

                return;
            }
            else if ((time - now).TotalSeconds < 300)
            {
                await e.ReplyToOriginal("提示时间不可设置为 5 分钟内的目标");

                return;
            }
            try
            {
                await TipMessageService.AddTipMessage(TipTargetType.QQGroup, e.SourceGroup, time, message);

                await e.ReplyToOriginal("已添加单次提示信息");
            }
            catch (Exception ex)
            {
                await e.ReplyToOriginal(ex.Message);
            }
        }
Ejemplo n.º 6
0
        public static async void DisableAutoLink(SoraMessage e)
        {
            QQGroupSetting data = await Database.FindAsync <QQGroupSetting>(x => x.Group == e.SourceGroup.Id);

            if (data == null || !data.SmartMinecraftLink)
            {
                await e.ReplyToOriginal("本群未启用该功能,无需禁用");

                return;
            }
            data.SmartMinecraftLink = false;
            await Database.UpdateAsync(data).ContinueWith(async x =>
            {
                if (x.Result > 0)
                {
                    await e.ReplyToOriginal("本群已成功禁用mojira智能解析功能");
                }
                else if (x.IsFaulted && x.Exception != null)
                {
                    await e.ReplyToOriginal(new StringBuilder()
                                            .AppendLine("因异常导致功能禁用失败,错误信息:")
                                            .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                            .ToString());
                }
                else
                {
                    await e.ReplyToOriginal("因未知原因导致功能禁用失败,请稍后重试");
                }
            });
        }
Ejemplo n.º 7
0
        public static async void RemoveJiraListener(SoraMessage e)
        {
            SubscribeList data = await Database.FindAsync <SubscribeList>(
                x
                => x.Platform == "qq group" &&
                x.Type == "minecraft jira" &&
                x.Target == "java" &&
                x.Listener == e.SourceGroup.Id.ToString());

            if (data == null)
            {
                await e.ReplyToOriginal("本群未订阅该目标,请检查输入是否正确");

                return;
            }
            await Database.DeleteAsync(data).ContinueWith(async x =>
            {
                if (x.Result > 0)
                {
                    await e.ReplyToOriginal("订阅项目已移除");
                }
                else if (x.IsFaulted && x.Exception != null)
                {
                    await e.ReplyToOriginal(new StringBuilder()
                                            .AppendLine("订阅项目因异常导致移除失败,错误信息:")
                                            .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                            .ToString());
                }
                else
                {
                    await e.AutoAtReply("订阅项目因未知原因导致移除失败,请稍后重试");
                }
            });
        }
Ejemplo n.º 8
0
        public static async void TipRemove(SoraMessage e, int id)
        {
            var tip = await TipMessageService.GetTipMessageById(id);

            if (tip != null && tip.TargetType == TipTargetType.QQGroup && tip.TargetID == e.SourceGroup.Id)
            {
                await tip.DeleteAsync();

                await e.ReplyToOriginal("操作成功");
            }
            await e.ReplyToOriginal($"不存在ID为 {id} 的提示消息");
        }
Ejemplo n.º 9
0
 public static async void CalcMath(SoraMessage e, string expr)
 {
     try
     {
         double result = Tools.CalcTool.GetExprValue(expr.Replace(" ", ""));
         await e.ReplyToOriginal($"{expr} = {result}");
     }
     catch
     {
         await e.ReplyToOriginal("操作失败");
     }
 }
Ejemplo n.º 10
0
        static async Task <string> GetImageUrl(SoraMessage e)
        {
            var imglist = e.Message.GetAllImage();

            if (imglist.Count <= 0)
            {
                await e.ReplyToOriginal("未检测到任何图片");

                return(null);
            }
            await e.ReplyToOriginal("请稍后");

            return((await e.SoraApi.GetImage(imglist.First().ImgFile)).url);
        }
Ejemplo n.º 11
0
        public static async void SearchOrigin(SoraMessage e, string poem)
        {
            try
            {
                var result = await Tools.Poem.GetOrigin(SoraMessage.Escape(poem));

                await e.ReplyToOriginal(result);

                await e.RemoveCoins(2);
            }
            catch (Exception ex)
            {
                await e.ReplyToOriginal(ex.Message);
            }
        }
Ejemplo n.º 12
0
        public static async void Normal(SoraMessage e, string origin)
        {
            try
            {
                var trans = NBNHHSH.Get(origin);
                if (trans.Length > 0)
                {
                    await e.ReplyToOriginal($"{origin} 的意思可能为" + Environment.NewLine + string.Join(" | ", trans));

                    return;
                }
            }
            catch
            { }
            await e.ReplyToOriginal($"{origin} 未能成功获取到猜测内容");
        }
Ejemplo n.º 13
0
        public static async void Normal(SoraMessage e)
        {
            try
            {
                var           h  = Library.Roll.Model.HistoryToday.Today();
                StringBuilder sb = new();
                sb.AppendLine("[" + DateTime.Today.ToString("yyyy-MM-dd") + "]");
                sb.AppendJoin(Environment.NewLine, h);
                if (h.Length > 30)
                {
                    var bin = UbuntuPastebin.Paste(sb.ToString(), "text", "Hitsory Today");
                    await e.ReplyToOriginal(new StringBuilder()
                                            .AppendLine("数据过多,请前往以下链接查看")
                                            .Append(bin).ToString());
                }
                else
                {
                    await e.Reply(sb.ToString());
                }
                await e.RemoveCoins(3);

                await e.UpdateGroupCooldown("historytoday");
            }
            catch
            {
                await e.Reply("数据获取失败,请稍后再试");
            }
        }
Ejemplo n.º 14
0
 public static async void GetMojiraList(SoraMessage e, DateTime from, DateTime to)
 {
     Issue[] issues = null;
     try
     {
         issues = JiraExtension.GetMCFixedIssues(from, to);
     }
     catch (Exception ex)
     {
         ConsoleLog.Error("Minecraft Jira Checker", ConsoleLog.ErrorLogBuilder(ex));
         await e.ReplyToOriginal(new StringBuilder()
                                 .AppendLine("获取信息时发生错误:")
                                 .Append(ex.GetFormatString())
                                 .ToString());
     }
     if (issues.Length > 0)
     {
         await e.ReplyToOriginal(new StringBuilder()
                                 .AppendLine("[Minecraft Jira]")
                                 .AppendLine("哇哦,Bugjang杀死了这些虫子:")
                                 .AppendLine(string.Join(Environment.NewLine, issues.Select(x => x.Title)))
                                 .Append($"统计时间: {from:yyyy-MM-dd HH:mm} ~ {to:yyyy-MM-dd HH:mm}")
                                 .ToString());
     }
     else
     {
         await e.ReplyToOriginal(new StringBuilder()
                                 .AppendLine("[Minecraft Jira]")
                                 .AppendLine("可恶,这段时间Bugjang一个虫子也没有杀")
                                 .Append($"统计时间: {from:yyyy-MM-dd HH:mm} ~ {to:yyyy-MM-dd HH:mm}")
                                 .ToString());
     }
 }
Ejemplo n.º 15
0
        public static async void GetIllustDetail(SoraMessage e, int id)
        {
            var detail = await Illust.Get(id);

            if (detail == null)
            {
                await e.ReplyToOriginal("数据获取失败,请稍后再试");
            }
            else
            {
                ArrayList msg = new();
                foreach (var img in detail.Images)
                {
                    msg.Add(CQCode.CQImage(ImageUrls.ToPixivCat(img.Medium)));
                }
                msg.Add(new StringBuilder().AppendLine()
                        .AppendLine(detail.Title)
                        .AppendLine($"Author: {detail.Author}")
                        .AppendLine(detail.Caption)
                        .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}")
                        .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}")
                        .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}")
                        .Append(detail.Url)
                        .ToString());
                await e.Reply(msg.ToArray());

                await e.RemoveCoins(5);
            }
        }
Ejemplo n.º 16
0
        public static async void EnableAutoLink(SoraMessage e)
        {
            QQGroupSetting data = await Database.FindAsync <QQGroupSetting>(x => x.Group == e.SourceGroup.Id);

            if (data != null)
            {
                if (data.SmartPixivLink)
                {
                    await e.ReplyToOriginal("本群已启用该功能,无需再次启用");

                    return;
                }
                data.SmartPixivLink = true;
                await Database.UpdateAsync(data).ContinueWith(async x =>
                {
                    if (x.Result > 0)
                    {
                        await e.ReplyToOriginal("本群已成功启用pixiv智能解析功能");
                    }
                    else if (x.IsFaulted && x.Exception != null)
                    {
                        await e.ReplyToOriginal(new StringBuilder()
                                                .AppendLine("因异常导致功能启用失败,错误信息:")
                                                .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                .ToString());
                    }
                    else
                    {
                        await e.ReplyToOriginal("因未知原因导致功能启用失败,请稍后重试");
                    }
                });
            }
            else
            {
                await Database.InsertAsync(new QQGroupSetting()
                {
                    Group          = e.SourceGroup.Id,
                    SmartPixivLink = true
                }).ContinueWith(async x =>
                {
                    if (x.Result > 0)
                    {
                        await e.ReplyToOriginal("本群已成功启用pixiv智能解析功能");
                    }
                    else if (x.IsFaulted && x.Exception != null)
                    {
                        await e.ReplyToOriginal(new StringBuilder()
                                                .AppendLine("因异常导致功能启用失败,错误信息:")
                                                .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                .ToString());
                    }
                    else
                    {
                        await e.ReplyToOriginal("因未知原因导致功能启用失败,请稍后重试");
                    }
                });
            }
        }
Ejemplo n.º 17
0
        public static async void DoublePing(SoraMessage e)
        {
            var receive     = (DateTime.Now - e.Time).TotalMilliseconds;
            var currentTime = DateTime.Now;

            var(status, _) = await e.ReplyToOriginal("Pong!");

            var send = (DateTime.Now - currentTime).TotalMilliseconds;

            if (status == Sora.Enumeration.ApiType.APIStatusType.OK)
            {
                await e.ReplyToOriginal(new StringBuilder()
                                        .AppendLine("[Double Ping Result]")
                                        .AppendLine($"Receive: {receive:F0} ms")
                                        .AppendLine($"Send: {send:F0} ms")
                                        .Append($"Send Status: {status}")
                                        .ToString());
            }
        }
Ejemplo n.º 18
0
 public static async void MOJIRA(SoraMessage e, string id)
 {
     if (!Regex.IsMatch(id, @"^MC(PE)?-\d+$"))
     {
         await e.ReplyToOriginal($"不合法的ID指定:{id}");
     }
     else
     {
         try
         {
             await e.ReplyToOriginal(GetIssueInfo(id));
         }
         catch (Exception ex)
         {
             await e.ReplyToOriginal(new StringBuilder()
                                     .AppendLine("获取信息时发生错误:")
                                     .Append(ex.GetFormatString())
                                     .ToString());
         }
     }
 }
Ejemplo n.º 19
0
        public static async void AddJiraListener(SoraMessage e)
        {
            SubscribeList data = await Database.FindAsync <SubscribeList>(
                x
                => x.Platform == "qq group" &&
                x.Type == "minecraft jira" &&
                x.Target == "java" &&
                x.Listener == e.SourceGroup.Id.ToString());

            if (data != null)
            {
                await e.ReplyToOriginal("本群已订阅该目标,请检查输入是否正确");

                return;
            }
            await Database.InsertAsync(new SubscribeList()
            {
                Platform = "qq group",
                Type     = "minecraft jira",
                Target   = "java",
                Listener = e.SourceGroup.Id.ToString()
            }).ContinueWith(async x =>
            {
                if (x.Result > 0)
                {
                    await e.ReplyToOriginal("订阅项目已添加,如果该目标曾经未被任何人订阅过那么将会在下一次检查时发送一次初始化广播信息");
                }
                else if (x.IsFaulted && x.Exception != null)
                {
                    await e.ReplyToOriginal(new StringBuilder()
                                            .AppendLine("订阅项目因异常导致添加失败,错误信息:")
                                            .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                            .ToString());
                }
                else
                {
                    await e.ReplyToOriginal("订阅项目因未知原因导致添加失败,请稍后重试");
                }
            });
        }
Ejemplo n.º 20
0
        public static async void ChinaDiagnosisCity(SoraMessage e)
        {
            var now = DateTime.Now;

            if ((now - lastUpdated).TotalSeconds >= 60)
            {
                if (!Covid19Api.Update())
                {
                    await e.ReplyToOriginal("数据获取失败,请稍后再试");

                    return;
                }
            }
            var chinaData = Covid19Api.InWorld.AreaList.FirstOrDefault(x => x.Name == "中国");

            if (default(Covid19DateReport).Equals(chinaData))
            {
                await e.ReplyToOriginal("数据获取失败,请稍后再试");

                return;
            }
            var cityList = chinaData.Children.Where(x => x.ExistingDiagnosed > 0)
                           .OrderBy(x => x.ExistingDiagnosed)
                           .Select(x => $"{x.Name} - 当前确诊 {x.ExistingDiagnosed} 人");

            if (cityList.Any())
            {
                var sb = new StringBuilder();
                sb.AppendLine($"以下{cityList.Count()}个城市存在新冠确诊患者:");
                sb.AppendJoin(Environment.NewLine, cityList);
                sb.AppendLine().AppendLine("数据更新时间: " + Covid19Api.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"));
                sb.Append("数据来源: ").Append(Covid19Api.ApiHost);
                await e.Reply(sb.ToString());
            }
            else
            {
                await e.Reply("未找到存在确诊患者的城市");
            }
        }
Ejemplo n.º 21
0
        public static async void Search(SoraMessage e, string keyword)
        {
            var search = await CloudMusicApi.SearchSong(keyword);

            if (search != null && search.Length > 0)
            {
                Play(e, search[0].Id);
            }
            else
            {
                await e.ReplyToOriginal("未搜索到相关结果");
            }
        }
Ejemplo n.º 22
0
        public static async void Normal(SoraMessage e, string id)
        {
            try
            {
                var info = Library.Roll.Model.Logistics.Get(id);
                await e.Reply(info.ToString());

                await e.RemoveCoins(15);
            }
            catch
            {
                await e.ReplyToOriginal("快递详情获取失败,请稍后再试");
            }
        }
Ejemplo n.º 23
0
        public static async void Normal(SoraMessage e)
        {
            var now = DateTime.Now;

            if ((now - lastUpdated).TotalSeconds >= 60)
            {
                if (!Covid19Api.Update())
                {
                    await e.ReplyToOriginal("数据获取失败,请稍后再试");

                    return;
                }
            }
            await e.Reply(Covid19Api.ToString());
        }
Ejemplo n.º 24
0
        static async Task Worker(SoraMessage e, Func <Image <Rgba32>, Image <Rgba32> > func)
        {
            try
            {
                var url = await GetImageUrl(e);

                if (url == null)
                {
                    return;
                }
                var gif = await DownloadImage(url);

                var product = func.Invoke(gif);
                await SendGif(e, product);
            }
            catch (Exception ex)
            {
                ConsoleLog.Error("Gif Generator", ex.GetFormatString());
                await e.ReplyToOriginal("因发生异常导致图像生成失败,", ex.Message);
            }
        }
Ejemplo n.º 25
0
        public static async void ServerStatus(SoraMessage e, string target)
        {
            var    x    = _ServerRegex.Match(target);
            string host = x.Groups["host"].Value;
            ushort port = 25565;

            if (ushort.TryParse(x.Groups["port"].Value, out ushort _port))
            {
                port = _port;
            }
            ServerInfo info = new ServerInfo(host, port);
            await info.StartGetServerInfoAsync();

            if (info.State == ServerInfo.StateType.GOOD)
            {
                var sb = new StringBuilder();
                sb.AppendLine("[Minecraft Server Status]");
                sb.AppendLine($"IP: {host}:{port}");
                sb.AppendLine($"Version: {info.GameVersion}");
                sb.AppendLine($"Players: {info.CurrentPlayerCount} / {info.MaxPlayerCount}");
                sb.AppendLine($"Latency: {info.Ping}ms");
                sb.AppendLine($"MOTD:").Append(info.MOTD);
                if (info.IconData != null)
                {
                    var icon = new MemoryImage(new Bitmap(new MemoryStream(info.IconData)));
                    await e.Reply(CQCode.CQImage(icon.ToBase64File()), Environment.NewLine, sb.ToString());
                }
                else
                {
                    await e.Reply(sb.ToString());
                }
            }
            else
            {
                await e.ReplyToOriginal("未能成功获取到目标服务器的数据,可能为参数输入错误或目标已离线");
            }
        }
Ejemplo n.º 26
0
        public static async void Play(SoraMessage e, long id)
        {
            var detail = await CloudMusicApi.GetSongDetail(id);

            if (detail == null)
            {
                await e.ReplyToOriginal("曲目信息获取失败");
            }
            else
            {
                var url = await CloudMusicApi.GetSongUrl(id, 128000);

                if (url.Id == detail.Id && url.Id == id)
                {
                    await e.Reply(CQCode.CQImage(detail.Album.GetPicUrl(512, 512)),
                                  new StringBuilder().AppendLine()
                                  .AppendLine("♬ " + detail.Name)
                                  .AppendLine("✎ " + string.Join(" / ", detail.Artists))
                                  .AppendLine(detail.Url)
                                  .Append("√ 曲目链接已解析,正在下载中……")
                                  .ToString());

                    await e.Reply(CQCode.CQRecord(url.Url));
                }
                else
                {
                    await e.Reply(CQCode.CQImage(detail.Album.GetPicUrl(512, 512)),
                                  new StringBuilder().AppendLine()
                                  .AppendLine("♬ " + detail.Name)
                                  .AppendLine("✎ " + string.Join(" / ", detail.Artists))
                                  .AppendLine(detail.Url)
                                  .Append("× 解析曲目链接失败")
                                  .ToString());
                }
            }
        }
Ejemplo n.º 27
0
        public static async void DiagnosisTop10(SoraMessage e)
        {
            var now = DateTime.Now;

            if ((now - lastUpdated).TotalSeconds >= 60)
            {
                if (!Covid19Api.Update())
                {
                    await e.ReplyToOriginal("数据获取失败,请稍后再试");

                    return;
                }
            }
            var list = Covid19Api.InWorld.AreaList.Where(x => x.ExistingDiagnosed > 0)
                       .OrderByDescending(x => x.ExistingDiagnosed).Take(10)
                       .Select(x => $"{x.Name} - 当前确诊 {x.ExistingDiagnosed} 人,距昨日 {Utils.ToSignNumberString(x.DifferenceExistingDiagnosed)} 人");
            var sb = new StringBuilder();

            sb.AppendLine($"新冠严重程度排行前10的国家");
            sb.AppendJoin(Environment.NewLine, list);
            sb.AppendLine().AppendLine("数据更新时间: " + Covid19Api.UpdateTime.ToString("yyyy-MM-dd HH:mm:ss"));
            sb.Append("数据来源: ").Append(Covid19Api.ApiHost);
            await e.Reply(sb.ToString());
        }
Ejemplo n.º 28
0
 public static async void Login(SoraMessage e)
 {
     await Task.Run(() => Library.Bilibili.Bilibili.QRCodeLoginRequest(
                        async(bitmap) =>
     {
         if (e.IsGroupMessage)
         {
             await e.ReplyToOriginal("登录任务已建立,请前往私聊等待登录二维码的发送");
         }
         else
         {
             await e.ReplyToOriginal("登录任务已建立,请等待登录二维码的发送");
         }
         var qr   = new MemoryImage(bitmap);
         var path = qr.ToBase64File();
         await e.SendPrivateMessage(CQCode.CQImage(path), "\n请使用Bilibili客户端扫码登录");
     },
                        async() => await e.SendPrivateMessage("检测到扫描事件,请在客户端中确认登录"),
                        async(cookie) =>
     {
         if (int.TryParse(cookie.Split(";").Where(x => x.StartsWith("DedeUserID=")).First()[11..], out var id))
         {
             await e.SendPrivateMessage("登录成功\n数据储存中……");
             var data = await Database.FindAsync <UserData>(x => x.QQ == e.Sender.Id || x.Bilibili == id);
             if (data != null)
             {
                 data.QQ             = e.Sender.Id;
                 data.Bilibili       = id;
                 data.BilibiliCookie = cookie;
                 await Database.UpdateAsync(data).ContinueWith(async x =>
                 {
                     if (x.Result > 0)
                     {
                         await e.SendPrivateMessage("记录数据已更新");
                     }
                     else if (x.IsFaulted && x.Exception != null)
                     {
                         await e.SendPrivateMessage(new StringBuilder()
                                                    .AppendLine("记录数据因异常导致更新失败,错误信息:")
                                                    .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                    .ToString());
                     }
                     else
                     {
                         await e.SendPrivateMessage("记录数据因未知原因导致更新失败,请稍后重试");
                     }
                 });
             }
             else
             {
                 data = new()
                 {
                     QQ             = e.Sender.Id,
                     Bilibili       = id,
                     BilibiliCookie = cookie
                 };
                 await Database.InsertAsync(data).ContinueWith(async x =>
                 {
                     if (x.Result > 0)
                     {
                         await e.SendPrivateMessage("记录数据已添加");
                     }
                     else if (x.IsFaulted && x.Exception != null)
                     {
                         await e.SendPrivateMessage(new StringBuilder()
                                                    .AppendLine("记录数据因异常导致更新失败,错误信息:")
                                                    .Append(ConsoleLog.ErrorLogBuilder(x.Exception))
                                                    .ToString());
                     }
                     else
                     {
                         await e.SendPrivateMessage("记录数据因未知原因导致更新失败,请稍后重试");
                     }
                 });
             }
         }
Ejemplo n.º 29
0
 public static async void Ping(SoraMessage e) => await e.ReplyToOriginal("Pong!");
Ejemplo n.º 30
0
        public static async void Coins(SoraMessage e)
        {
            var c = await e.GetCoins();

            await e.ReplyToOriginal($"当前持有幻币 {c.Total} 枚{Environment.NewLine}(其中 {c.FreeCoins} 枚幻币为当日免费幻币)");
        }