diff --git a/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/emmm.jpg b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/emmm.jpg new file mode 100644 index 00000000..70e557c3 Binary files /dev/null and b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/emmm.jpg differ diff --git a/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/error.jpg b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/error.jpg new file mode 100644 index 00000000..ca6a5112 Binary files /dev/null and b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/error.jpg differ diff --git a/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/shenyuanjiesuan.png b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/shenyuanjiesuan.png new file mode 100644 index 00000000..b75489e6 Binary files /dev/null and b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/shenyuanjiesuan.png differ diff --git a/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/welcome.gif b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/welcome.gif new file mode 100644 index 00000000..a4704785 Binary files /dev/null and b/Theresa3rd-Bot/TheresaBot.Main/BotImg/face/welcome.gif differ diff --git "a/Theresa3rd-Bot/TheresaBot.Main/BotImg/localSetu/\345\276\267\344\270\275\350\216\216/71421964_p1.jpg" "b/Theresa3rd-Bot/TheresaBot.Main/BotImg/localSetu/\345\276\267\344\270\275\350\216\216/71421964_p1.jpg" new file mode 100644 index 00000000..005e5e22 Binary files /dev/null and "b/Theresa3rd-Bot/TheresaBot.Main/BotImg/localSetu/\345\276\267\344\270\275\350\216\216/71421964_p1.jpg" differ diff --git a/Theresa3rd-Bot/TheresaBot.Main/Business/PixivBusiness.cs b/Theresa3rd-Bot/TheresaBot.Main/Business/PixivBusiness.cs index 284920a5..f1085e61 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Business/PixivBusiness.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Business/PixivBusiness.cs @@ -84,10 +84,10 @@ public async Task getRandomWorkInSubscribeAsync(long groupId, boo for (int j = 0; j < loopWorkTimes; j++) { PixivUserWorkInfo pixivUserWorkInfo = workList[new Random().Next(0, workList.Count)]; - if (pixivUserWorkInfo.IsImproper()) continue; + if (pixivUserWorkInfo.IsImproper) continue; if (pixivUserWorkInfo.hasBanTag() != null) continue; - if (pixivUserWorkInfo.isR18() && includeR18 == false) continue; - if (pixivUserWorkInfo.isAI() && includeAI == false) continue; + if (pixivUserWorkInfo.IsR18 && includeR18 == false) continue; + if (pixivUserWorkInfo.IsAI && includeAI == false) continue; PixivWorkInfo pixivWorkInfo = await PixivHelper.GetPixivWorkInfoAsync(pixivUserWorkInfo.id); if (pixivWorkInfo is null) continue; if (pixivWorkInfo.bookmarkCount < 100) continue; @@ -135,10 +135,10 @@ public async Task getRandomWorkInFollowAsync(bool includeR18, boo for (int i = 0; i < loopWorkTimes; i++) { PixivUserWorkInfo pixivUserWorkInfo = workList[new Random().Next(0, workList.Count)]; - if (pixivUserWorkInfo.IsImproper()) continue; + if (pixivUserWorkInfo.IsImproper) continue; if (pixivUserWorkInfo.hasBanTag() != null) continue; - if (pixivUserWorkInfo.isR18() && includeR18 == false) continue; - if (pixivUserWorkInfo.isAI() && includeAI == false) continue; + if (pixivUserWorkInfo.IsR18 && includeR18 == false) continue; + if (pixivUserWorkInfo.IsAI && includeAI == false) continue; PixivWorkInfo pixivWorkInfo = await PixivHelper.GetPixivWorkInfoAsync(pixivUserWorkInfo.id); if (pixivWorkInfo is null) continue; if (pixivWorkInfo.bookmarkCount < 100) continue; @@ -409,6 +409,9 @@ public async Task scanAndPushUserAsync(SubscribeTask subscribeTask, PixivUserSca int getCount = 5; string userId = subscribeTask.SubscribeCode; int subscribeId = subscribeTask.SubscribeId; + List groupIds = subscribeTask.GroupIdList; + bool isShowAIs = groupIds.IsShowAISetu(); + bool isShowR18s = groupIds.IsShowR18Setu(); PixivUserInfo pixivUserInfo = await PixivHelper.GetPixivUserInfoAsync(userId); if (pixivUserInfo is null) return; Dictionary illusts = pixivUserInfo?.illusts; @@ -421,6 +424,9 @@ public async Task scanAndPushUserAsync(SubscribeTask subscribeTask, PixivUserSca { if (++index > getCount) break; if (workInfo is null || string.IsNullOrWhiteSpace(workInfo.id)) continue; + if (workInfo.IsImproper) continue; + if (isShowAIs == false && workInfo.IsAI) continue; + if (isShowR18s == false && workInfo.IsR18) continue; if (shelfLife > 0 && workInfo.createDate < DateTime.Now.AddSeconds(-1 * shelfLife)) break; if (subscribeRecordDao.checkExists(subscribeTask.SubscribeType, workInfo.id)) continue; scanReport.ScanWork++; @@ -453,6 +459,9 @@ public async Task scanAndPushTagAsync(SubscribeTask subscribeTask, PixivTagScanR { string tagNames = subscribeTask.SubscribeCode; int subscribeId = subscribeTask.SubscribeId; + List groupIds = subscribeTask.GroupIdList; + bool isShowAIs = groupIds.IsShowAISetu(); + bool isShowR18s = groupIds.IsShowR18Setu(); string searchWord = toPixivSearchWord(tagNames); int maxScan = BotConfig.SubscribeConfig.PixivTag.MaxScan; int shelfLife = BotConfig.SubscribeConfig.PixivTag.ShelfLife; @@ -462,6 +471,9 @@ public async Task scanAndPushTagAsync(SubscribeTask subscribeTask, PixivTagScanR try { if (item is null || string.IsNullOrWhiteSpace(item.id)) continue; + if (item.IsImproper) continue; + if (isShowAIs == false && item.IsAI) continue; + if (isShowR18s == false && item.IsR18) continue; if (shelfLife > 0 && item.createDate < DateTime.Now.AddSeconds(-1 * shelfLife)) break; if (subscribeRecordDao.checkExists(subscribeTask.SubscribeType, item.id)) continue; scanReport.ScanWork++; @@ -495,6 +507,9 @@ public async Task scanAndPushTagAsync(SubscribeTask subscribeTask, PixivTagScanR public async Task scanAndPushFollowAsync(PixivUserScanReport scanReport, Func, Task> pushAsync) { int pageIndex = 1; + List groupIds = BotConfig.PermissionsConfig.SubscribeGroups; + bool isShowAIs = groupIds.IsShowAISetu(); + bool isShowR18s = groupIds.IsShowR18Setu(); PixivFollowLatest pageOne = await PixivHelper.GetPixivFollowLatestAsync(pageIndex); if (pageOne?.page?.ids is null) return; int shelfLife = BotConfig.SubscribeConfig.PixivTag.ShelfLife; @@ -508,12 +523,15 @@ public async Task scanAndPushFollowAsync(PixivUserScanReport scanReport, Func 0 && pixivWorkInfo.createDate < DateTime.Now.AddSeconds(-1 * shelfLife)) break; SubscribePO dbSubscribe = getOrInsertUserSubscribe(pixivWorkInfo); SubscribeRecordPO subscribeRecord = toSubscribeRecord(pixivWorkInfo, dbSubscribe.Id); subscribeRecord = subscribeRecordDao.Insert(subscribeRecord); PixivSubscribe pixivSubscribe = new PixivSubscribe(subscribeRecord, pixivWorkInfo); - await pushAsync(pixivSubscribe, BotConfig.PermissionsConfig.SubscribeGroups); + await pushAsync(pixivSubscribe, groupIds); } catch (Exception ex) { diff --git a/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs b/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs index 7d639193..b5a4c617 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Common/BotConfig.cs @@ -7,7 +7,7 @@ namespace TheresaBot.Main.Common { public static class BotConfig { - public const string BotVersion = "v0.8.2"; + public const string BotVersion = "v0.8.3"; public const string BotHomepage = "https://www.theresa3rd.cn"; public static GeneralConfig GeneralConfig = new GeneralConfig(); public static PixivConfig PixivConfig = new PixivConfig(); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Font/simsun.ttc b/Theresa3rd-Bot/TheresaBot.Main/Font/simsun.ttc new file mode 100644 index 00000000..5f22ce3f Binary files /dev/null and b/Theresa3rd-Bot/TheresaBot.Main/Font/simsun.ttc differ diff --git a/Theresa3rd-Bot/TheresaBot.Main/Handler/LolisukiHandler.cs b/Theresa3rd-Bot/TheresaBot.Main/Handler/LolisukiHandler.cs index 2d7a0973..04a92f39 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Handler/LolisukiHandler.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Handler/LolisukiHandler.cs @@ -42,7 +42,7 @@ public async Task lolisukiSearchAsync(GroupCommand command) List dataList; int r18Mode = isShowR18 ? 2 : 0; int aiMode = isShowAI ? 2 : 0; - string levelStr = getLevelStr(isShowR18); + string levelStr = getLevelStr(isShowR18, BotConfig.SetuConfig?.Lolisuki?.Level); if (string.IsNullOrEmpty(tagStr)) { @@ -101,7 +101,7 @@ public async Task sendTimingSetuAsync(TimingSetuTimer timingSetuTimer, long grou int margeEachPage = 5; bool isShowAI = groupId.IsShowAISetu(); bool isShowR18 = groupId.IsShowR18Setu(); - string levelStr = getLevelStr(isShowR18); + string levelStr = getLevelStr(isShowR18, BotConfig.TimingSetuConfig?.LolisukiLevel); bool sendMerge = timingSetuTimer.SendMerge; int aiMode = isShowAI ? 2 : 0; int r18Mode = isShowR18 ? 2 : 0; @@ -135,14 +135,12 @@ private async Task getSetuContent(LolisukiData data, long groupId) return new SetuContent(setuInfo, setuFiles); } - private string getLevelStr(bool isShowR18) + private string getLevelStr(bool isShowR18, string settingLevel) { try { - string levelStr = BotConfig.SetuConfig.Lolisuki.Level; - if (string.IsNullOrWhiteSpace(levelStr)) return $"{(int)LolisukiLevel.Level0}-{(int)LolisukiLevel.Level3}"; - - string[] levelArr = levelStr.Split('-', StringSplitOptions.RemoveEmptyEntries); + if (string.IsNullOrWhiteSpace(settingLevel)) return $"{(int)LolisukiLevel.Level0}-{(int)LolisukiLevel.Level2}"; + string[] levelArr = settingLevel.Split('-', StringSplitOptions.RemoveEmptyEntries); string minLevelStr = levelArr[0].Trim(); string maxLevelStr = levelArr.Length > 1 ? levelArr[1].Trim() : levelArr[0].Trim(); int minLevel = int.Parse(minLevelStr); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Handler/PixivRankingHandler.cs b/Theresa3rd-Bot/TheresaBot.Main/Handler/PixivRankingHandler.cs index 65b6a4d3..784dd0c7 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Handler/PixivRankingHandler.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Handler/PixivRankingHandler.cs @@ -124,7 +124,7 @@ private async Task sendPreviewFileAsync(PixivRankingTimer rankingTimer, PixivRan List PreviewFilePaths = pixivRankingInfo.PreviewFilePaths; if (PreviewFilePaths is null || PreviewFilePaths.IsFilesExists() == false) { - PreviewFilePaths = createPreviewImg(pixivRankingInfo); + PreviewFilePaths = await createPreviewImgAsync(pixivRankingInfo); pixivRankingInfo.PreviewFilePaths = PreviewFilePaths; } @@ -132,11 +132,17 @@ private async Task sendPreviewFileAsync(PixivRankingTimer rankingTimer, PixivRan setuContents.Add(new SetuContent(templateMsg)); setuContents.AddRange(PreviewFilePaths.Select(o => new SetuContent(new FileInfo(o)))); setuContents.AddRange(rankingBusiness.getRankAndPids(pixivRankingInfo, 10)); + foreach (var groupId in rankingTimer.Groups) { if (rankingMode.IsR18 && groupId.IsShowR18SetuImg() == false) continue; await Session.SendGroupMessageAsync(groupId, templateMsg); await Task.Delay(1000); + } + + foreach (var groupId in rankingTimer.Groups) + { + if (rankingMode.IsR18 && groupId.IsShowR18SetuImg() == false) continue; await SendGroupSetuAsync(setuContents, groupId, true); await Task.Delay(1000); } @@ -211,7 +217,7 @@ private async Task replyRankingInfo(GroupCommand command, PixivRankingMode ranki List PreviewFilePaths = pixivRankingInfo.PreviewFilePaths; if (PreviewFilePaths is null || PreviewFilePaths.IsFilesExists() == false) { - PreviewFilePaths = createPreviewImg(pixivRankingInfo); + PreviewFilePaths = await createPreviewImgAsync(pixivRankingInfo); pixivRankingInfo.PreviewFilePaths = PreviewFilePaths; } @@ -246,7 +252,7 @@ private async Task replyRankingInfo(GroupCommand command, PixivRankingMode ranki } } - private List createPreviewImg(PixivRankingInfo rankingInfo) + private async Task> createPreviewImgAsync(PixivRankingInfo rankingInfo) { int startIndex = 0; int previewInPage = BotConfig.PixivRankingConfig.PreviewInPage; @@ -260,18 +266,18 @@ private List createPreviewImg(PixivRankingInfo rankingInfo) string fileName = $"{rankingMode.Code}_preview_{rankingInfo.RankingDate}_{startIndex}_{startIndex + previewInPage}.jpg"; string fullSavePath = Path.Combine(FilePath.GetPixivPreviewSavePath(), fileName); var partList = details.Skip(startIndex).Take(previewInPage).ToList(); - var previewFile = createPreviewImg(rankingInfo, partList, fullSavePath); + var previewFile = await createPreviewImgAsync(rankingInfo, partList, fullSavePath); if (previewFile is not null) fileInfos.Add(previewFile.FullName); startIndex += previewInPage; } return fileInfos; } - private FileInfo createPreviewImg(PixivRankingInfo rankingInfo, List datas, string savePath) + private async Task createPreviewImgAsync(PixivRankingInfo rankingInfo, List datas, string fullSavePath) { try { - return PixivRankingDrawHelper.DrawPreview(rankingInfo, datas, savePath); + return await PixivRankingDrawHelper.DrawPreview(rankingInfo, datas, fullSavePath); } catch (Exception ex) { @@ -281,6 +287,5 @@ private FileInfo createPreviewImg(PixivRankingInfo rankingInfo, List downAndComposeGifAsync(BaseWorkInfo workInfo) PixivUgoiraMeta pixivUgoiraMetaDto = await PixivHelper.GetPixivUgoiraMetaAsync(pixivIdStr); string zipHttpUrl = pixivUgoiraMetaDto.src; - string fullZipSavePath = Path.Combine(FilePath.GetTempSavePath(), $"{pixivId}.zip"); - FileInfo zipFile = await PixivHelper.DownPixivFileAsync(pixivIdStr, zipHttpUrl, fullZipSavePath); + FileInfo zipFile = await PixivHelper.DownPixivFileAsync(pixivIdStr, zipHttpUrl); if (zipFile == null) return null; string unZipDirPath = Path.Combine(FilePath.GetTempSavePath(), pixivIdStr); @@ -350,7 +349,7 @@ protected async Task downAndComposeGifAsync(BaseWorkInfo workInfo) } gif.SaveAsGif(fullGifSavePath); - FileHelper.DeleteFile(fullZipSavePath); + FileHelper.DeleteFile(zipFile); FileHelper.DeleteDirectory(unZipDirPath); return new FileInfo(fullGifSavePath); } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/BusinessHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/BusinessHelper.cs index 58cb3c54..12275790 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/BusinessHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/BusinessHelper.cs @@ -187,9 +187,7 @@ public static List GetErrorContents(this Exception ex, SendTarget s string template = BotConfig.GeneralConfig.ErrorMsg; if (string.IsNullOrWhiteSpace(template)) template = "出了点小问题,再试一次吧~"; if (template.StartsWith(" ") == false) template = " " + template; - List contents = new(); - if (string.IsNullOrEmpty(message) == false) contents.Add(new PlainContent(message)); - if (string.IsNullOrEmpty(ex.Message) == false) contents.Add(new PlainContent(ex.Message.cutString(200))); + List contents = new List(); contents.AddRange(template.SplitToChainAsync(sendTarget)); return contents; } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/CommandHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/CommandHelper.cs index 54d97831..e7015296 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/CommandHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/CommandHelper.cs @@ -3,6 +3,7 @@ using TheresaBot.Main.Common; using TheresaBot.Main.Invoker; using TheresaBot.Main.Model.Content; +using TheresaBot.Main.Type; namespace TheresaBot.Main.Helper { @@ -11,7 +12,7 @@ public static class CommandHelper public static async Task ReplyGroupSetuAndRevokeAsync(this GroupCommand command, SetuContent setuContent, int revokeInterval, bool sendImgBehind, bool isAt = false) { int[] msgIdArr = await command.ReplyGroupMessageAndRevokeAsync(setuContent, revokeInterval, sendImgBehind, isAt); - if (msgIdArr.Where(o => o < 0).Any()) + if (msgIdArr.Where(o => o < 0).Any() && BotConfig.PixivConfig.ImgResend != ResendType.None) { await Task.Delay(1000); SetuContent resendContent = setuContent.ToResendContent(BotConfig.PixivConfig.ImgResend); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/ContentHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/ContentHelper.cs index 85fab727..743da1a4 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/ContentHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/ContentHelper.cs @@ -7,7 +7,7 @@ public static class ContentHelper { public static SetuContent ToResendContent(this SetuContent setuContents, ResendType resendType) { - if (resendType == ResendType.WithoutImg) + if (resendType == ResendType.None) { return null; } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/FileHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/FileHelper.cs index 6a39d919..6a6e5d6f 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/FileHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/FileHelper.cs @@ -25,6 +25,7 @@ public static void DeleteFile(string fullFilePath) { try { + if (!File.Exists(fullFilePath)) return; File.Delete(fullFilePath); } catch (Exception ex) @@ -37,6 +38,7 @@ public static void DeleteFile(FileInfo fileInfo) { try { + if (fileInfo is null) return; fileInfo.Delete(); } catch (Exception ex) @@ -49,6 +51,7 @@ public static void DeleteDirectory(string directoryPath) { try { + if (!Directory.Exists(directoryPath)) return; Directory.Delete(directoryPath, true); } catch (Exception ex) diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/MathHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/MathHelper.cs index 321945c4..a4436216 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/MathHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/MathHelper.cs @@ -52,7 +52,7 @@ public static int getMaxPage(int total, int eachPage) /// public static string toPercent(this double number) { - return (number * 100).ToString("0.000") + "%"; + return (number * 100).ToString("0.00") + "%"; } } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/PermissionsHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/PermissionsHelper.cs index 6c30acbe..114abbc8 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/PermissionsHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/PermissionsHelper.cs @@ -74,6 +74,16 @@ public static bool IsShowR18SetuImg(this long groupId) return true; } + /// + /// 判断是否存在其中一个群可以显示R18内容 + /// + /// + /// + public static bool IsShowR18Setu(this List groupIds) + { + return groupIds.Where(o => o.IsShowR18Setu()).Any(); + } + /// /// 判断某一个群是否可以显示R18内容 /// diff --git a/Theresa3rd-Bot/TheresaBot.Main/Helper/PixivHelper.cs b/Theresa3rd-Bot/TheresaBot.Main/Helper/PixivHelper.cs index 01197601..95450b96 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Helper/PixivHelper.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Helper/PixivHelper.cs @@ -279,8 +279,8 @@ private static async Task DownPixivFileAsync(string url, Dictionary datas, string savePath) + public static async Task DrawPreview(PixivRankingInfo rankingInfo, List details, string fullSavePath) { - int row = 1; - int column = 1; + int areaX = 0; int areaY = 0; int startX = 0; int startY = 0; - int imgNum = datas.Count; - int maxRow = MathHelper.getMaxPage(imgNum, MaxColumn); - + var drawingList = await ArrangeDrawingAsync(details); + int maxRow = drawingList.Max(o => o.Row); int headAreaHeight = HeaderMargin + HeaderFontSize; int remarkAreaHeight = RemarkMargin + RemarkFontSize; - int workAreaWidth = MaxColumn * AreaWidth + (MaxColumn + 1) * AreaMargin; - int workAreaHeight = headAreaHeight + maxRow * AreaHeight + (maxRow + 1) * AreaMargin; + int workAreaWidth = MaxColumn * CellWidth + (MaxColumn + 1) * CellMargin; + int workAreaHeight = headAreaHeight + maxRow * CellHeight + (maxRow + 1) * CellMargin; int watermarkAreaHeight = WatermarkMargin + WatermarkFontSize; int canvasWidth = workAreaWidth; @@ -46,31 +47,67 @@ public static FileInfo DrawPreview(PixivRankingInfo rankingInfo, List> ArrangeDrawingAsync(List details) + { + int row = 1, column = 1; + var arrageList = new List(); + for (int i = 0; i < details.Count; i++) + { + bool isHorizontal = false; + SKBitmap originBitmap = null; + var detail = details[i]; + var imgFile = await GetDrawImgAsync(detail); + if (imgFile is not null) + { + using FileStream fileStream = File.OpenRead(imgFile.FullName); + originBitmap = SKBitmap.Decode(fileStream); + isHorizontal = originBitmap.IsHorizontal(); + } + int colSpan = isHorizontal ? 2 : 1; + if (column + colSpan > MaxColumn) + { + column = 1; + row++; + } + else + { + if (i > 0) column++; + } + arrageList.Add(new PixivRnakingDrawing(detail, originBitmap, isHorizontal, row, column)); + if (colSpan > 1) column = column + colSpan - 1; + } + return arrageList; } private static void DrawHeader(SKCanvas canvas, PixivRankingInfo rankingInfo, int startX, int startY) @@ -85,7 +122,7 @@ private static void DrawHeader(SKCanvas canvas, PixivRankingInfo rankingInfo, in Style = SKPaintStyle.Fill, TextAlign = SKTextAlign.Left, TextSize = HeaderFontSize, - Typeface = SKTypeface.FromFamilyName("SimSun") + Typeface = Typeface }; string headerText = $"{rankingInfo.RankingDate} {rankingInfo.RankingMode.Name}"; canvas.DrawText(headerText, new SKPoint(x, y), paint); @@ -103,13 +140,13 @@ private static void DrawRemark(SKCanvas canvas, PixivRankingInfo rankingInfo, in Style = SKPaintStyle.Fill, TextAlign = SKTextAlign.Left, TextSize = RemarkFontSize, - Typeface = SKTypeface.FromFamilyName("SimSun") + Typeface = Typeface }; - string headerText = $"图片信息:#排名 PID 点赞率%/收藏率%"; + string headerText = $"#排名 PID 点赞率%/收藏率%"; canvas.DrawText(headerText, new SKPoint(x, y), paint); } - private static void DrawDetails(SKCanvas canvas, PixivRankingDetail detail, int startX, int startY) + private static void DrawTitle(SKCanvas canvas, PixivRankingDetail detail, int startX, int startY, bool isHorizontal) { int x = startX; int y = startY; @@ -120,8 +157,8 @@ private static void DrawDetails(SKCanvas canvas, PixivRankingDetail detail, int IsAntialias = true, Style = SKPaintStyle.Fill, TextAlign = SKTextAlign.Left, - TextSize = DetailFontSize, - Typeface = SKTypeface.FromFamilyName("SimSun") + TextSize = TitleFontSize, + Typeface = Typeface }; PixivRankingContent content = detail.RankingContent; string likeRate = detail.WorkInfo.likeRate.toPercent(); @@ -130,23 +167,24 @@ private static void DrawDetails(SKCanvas canvas, PixivRankingDetail detail, int canvas.DrawText(detailText, new SKPoint(x, y), paint); } - private static void DrawImage(SKCanvas canvas, PixivRankingDetail detail, int startX, int startY) + private static void DrawImage(SKCanvas canvas, SKBitmap originBitmap, int startX, int startY, bool isR18, bool isHorizontal) { + if (originBitmap is null) return; int x = startX; - int y = startY + DetailFontSize; - FileInfo imgFile = GetDrawImg(detail).Result; - if (imgFile is null) imgFile = FilePath.GetDownErrorImg(); - if (imgFile is null) return; - using FileStream fileStream = File.OpenRead(imgFile.FullName); - using SKBitmap originBitmap = SKBitmap.Decode(fileStream); - double widthScale = Convert.ToDouble(IllustWidth) / originBitmap.Width; - double heightScale = Convert.ToDouble(IllustHeight) / originBitmap.Height; - double scale = Math.Min(widthScale, heightScale); + int y = startY + TitleFontSize / 2; + int drawWidth = isHorizontal ? CellWidth + CellMargin + CellWidth : IllustWidth; + int drawHeight = IllustHeight; + double scaleX = Convert.ToDouble(drawWidth) / originBitmap.Width; + double scaleY = Convert.ToDouble(drawHeight) / originBitmap.Height; + double scale = Math.Max(scaleX, scaleY); int imgWidth = (int)(originBitmap.Width * scale); int imgHeight = (int)(originBitmap.Height * scale); - using SKBitmap resizeBitmap = originBitmap.Resize(new SKImageInfo(imgWidth, imgHeight), SKFilterQuality.Low); - using SKBitmap drawBitmap = detail.WorkInfo.IsR18 ? resizeBitmap.Blur() : resizeBitmap; - canvas.DrawBitmap(drawBitmap, new SKPoint(x, y)); + var imgInfo = new SKImageInfo(imgWidth, imgHeight); + using SKBitmap resizeBitmap = originBitmap.Resize(imgInfo, SKFilterQuality.Low); + using SKBitmap drawBitmap = isR18 ? resizeBitmap.Blur() : resizeBitmap; + var source = new SKRect(0, 0, drawWidth, drawHeight); + var dest = new SKRect(x, y, x + drawWidth, y + drawHeight); + canvas.DrawBitmap(drawBitmap, source, dest); } private static void DrawWatermark(SKCanvas canvas, int startX, int startY) @@ -161,20 +199,22 @@ private static void DrawWatermark(SKCanvas canvas, int startX, int startY) Style = SKPaintStyle.Fill, TextAlign = SKTextAlign.Left, TextSize = WatermarkFontSize, - Typeface = SKTypeface.FromFamilyName("SimSun") + Typeface = Typeface }; - string watermarkText = $"Create by Theresa-Bot {BotConfig.BotVersion}"; + string watermarkText = $"Create by Theresa-Bot {BotConfig.BotVersion} Doc {BotConfig.BotHomepage}"; canvas.DrawText(watermarkText, new SKPoint(x, y), paint); } - private static async Task GetDrawImg(PixivRankingDetail detail) + private static async Task GetDrawImgAsync(PixivRankingDetail detail) { try { string imgSavePath = detail.ImageSavePath; if (File.Exists(imgSavePath)) return new FileInfo(imgSavePath); string fullFileName = detail.RankingContent.url.GetPreviewImgSaveName(detail.WorkInfo.illustId); - return await PixivHelper.DownPixivImgAsync(detail.WorkInfo.PixivId, detail.RankingContent.url, fullFileName); + FileInfo imgFile = await PixivHelper.DownPixivImgAsync(detail.WorkInfo.PixivId, detail.RankingContent.url, fullFileName); + if (imgFile is not null) return imgFile; + return FilePath.GetDownErrorImg(); } catch (Exception ex) { @@ -183,6 +223,29 @@ private static async Task GetDrawImg(PixivRankingDetail detail) } } + private static SKTypeface GetTypeface() + { + try + { + if (Directory.Exists(FontDir) == false) return null; + var fontDirectory = new DirectoryInfo(FontDir); + var fontFiles = fontDirectory.GetFiles(); + if (fontFiles.Length == 0) return null; + var firstFont = fontFiles.First(); + return SKTypeface.FromFile(firstFont.FullName); + } + catch (Exception ex) + { + LogHelper.Error(ex); + return null; + } + } + + private static bool IsHorizontal(this SKBitmap originBitmap) + { + return Convert.ToDouble(originBitmap.Width) / originBitmap.Height > 1.2; + } + private static SKBitmap Blur(this SKBitmap bitmap) { using SKImage blurImage = bitmap.Blur(BotConfig.PixivConfig.R18ImgBlur); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/Lolicon/LoliconResultV2.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/Lolicon/LoliconResultV2.cs index f109f94f..636abc97 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Model/Lolicon/LoliconResultV2.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/Lolicon/LoliconResultV2.cs @@ -25,26 +25,12 @@ public class LoliconDataV2 : BaseWorkInfo public string ext { get; set; } public long uploadDate { get; set; } public LoliconUrlsV2 urls { get; set; } - public override bool IsR18 - { - get { return r18; } - } - public override bool IsGif - { - get { return tags != null && tags.IsGif(); } - } - public override bool IsAI - { - get { return aiType > 1; } - } - public override bool IsImproper - { - get { return tags != null && tags.IsImproper(); } - } - public override string PixivId - { - get { return pid.ToString(); } - } + + public override bool IsR18 => r18; + public override bool IsGif => tags != null && tags.IsGif(); + public override bool IsAI => aiType > 1; + public override bool IsImproper => tags != null && tags.IsImproper(); + public override string PixivId => pid.ToString(); public override List getTags() => tags ?? new List(); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/Lolisuki/LolisukiResult.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/Lolisuki/LolisukiResult.cs index e0c8e259..f8d739b9 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Model/Lolisuki/LolisukiResult.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/Lolisuki/LolisukiResult.cs @@ -35,20 +35,9 @@ public class LolisukiData : BaseWorkInfo public List tags { get; set; } public List extags { get; set; } - public override bool IsGif - { - get { return tags != null && tags.IsGif(); } - } - - public override bool IsAI - { - get { return aiType > 1; } - } - - public override string PixivId - { - get { return pid.ToString(); } - } + public override bool IsGif => gif; + public override bool IsAI => aiType > 1; + public override string PixivId => pid.ToString(); public override bool IsR18 { diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivSearch.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivSearch.cs index be0809a4..9d0dd38a 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivSearch.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivSearch.cs @@ -1,4 +1,6 @@ -namespace TheresaBot.Main.Model.Pixiv +using TheresaBot.Main.Helper; + +namespace TheresaBot.Main.Model.Pixiv { public class PixivSearch { @@ -22,6 +24,7 @@ public class PixivSearchIllustManga public class PixivIllust { + public int aiType { get; set; } public string id { get; set; } public string illustTitle { get; set; } public int pageCount { get; set; } @@ -30,6 +33,13 @@ public class PixivIllust public string userName { get; set; } public DateTime createDate { get; set; } public DateTime updateDate { get; set; } + public List tags { get; set; } + public int xRestrict { get; set; } + + public bool IsAI => aiType > 1 || getTags().IsAI(); + public bool IsR18 => xRestrict > 0 || getTags().IsR18(); + public bool IsImproper => xRestrict > 1 || getTags().IsImproper(); + public List getTags() => tags ?? new List(); } } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivUserInfo.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivUserInfo.cs index 22d2c188..69f427a6 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivUserInfo.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivUserInfo.cs @@ -19,10 +19,11 @@ public class PixivUserWorkInfo public DateTime createDate { get; set; } public int xRestrict { get; set; } public int aiType { get; set; } - public bool IsImproper() => xRestrict > 1 || (tags != null && tags.IsImproper()); - public bool isR18() => xRestrict > 0 || (tags != null && tags.IsR18()); - public bool isAI() => aiType > 1 || (tags != null && tags.IsAI()); - public string hasBanTag() => tags?.hasBanTags(); + public bool IsImproper => xRestrict > 1 || getTags().IsImproper(); + public bool IsR18 => xRestrict > 0 || getTags().IsR18(); + public bool IsAI => aiType > 1 || getTags().IsAI(); + public string hasBanTag() => getTags().hasBanTags(); + public List getTags() => tags ?? new List(); } public class PixivUserExtraData diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivWorkInfo.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivWorkInfo.cs index 2b74a02a..9dbea19e 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivWorkInfo.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/Pixiv/PixivWorkInfo.cs @@ -31,7 +31,7 @@ public class PixivWorkInfo : BaseWorkInfo //xRestrict=1为R18,xRestrict=2为R18G public override bool IsR18 => xRestrict > 0 || getTags().IsR18(); - public override bool IsGif => getTags().IsGif(); + public override bool IsGif => illustType == 2; public override bool IsAI => aiType > 1 || getTags().IsAI(); diff --git a/Theresa3rd-Bot/TheresaBot.Main/Model/PixivRanking/PixivRnakingDrawing.cs b/Theresa3rd-Bot/TheresaBot.Main/Model/PixivRanking/PixivRnakingDrawing.cs new file mode 100644 index 00000000..8b64c225 --- /dev/null +++ b/Theresa3rd-Bot/TheresaBot.Main/Model/PixivRanking/PixivRnakingDrawing.cs @@ -0,0 +1,28 @@ +using SkiaSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace TheresaBot.Main.Model.PixivRanking +{ + public class PixivRnakingDrawing + { + public PixivRankingDetail RankingDetail { get; set; } + public SKBitmap OriginBitmap { get; set; } + public bool IsHorizontal { get; set; } + public int Row { get; set; } + public int Column { get; set; } + + public PixivRnakingDrawing(PixivRankingDetail rankingDetail, SKBitmap originBitmap, bool isHorizontal, int row, int column) + { + this.RankingDetail = rankingDetail; + this.OriginBitmap = originBitmap; + this.IsHorizontal = isHorizontal; + this.Row = row; + this.Column = column; + } + + } +} diff --git a/Theresa3rd-Bot/TheresaBot.Main/TheresaBot.Main.csproj b/Theresa3rd-Bot/TheresaBot.Main/TheresaBot.Main.csproj index a98b2d96..6eab34ea 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/TheresaBot.Main.csproj +++ b/Theresa3rd-Bot/TheresaBot.Main/TheresaBot.Main.csproj @@ -23,6 +23,7 @@ + @@ -45,4 +46,25 @@ + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + diff --git a/Theresa3rd-Bot/TheresaBot.Main/Timers/DownloadClearJob.cs b/Theresa3rd-Bot/TheresaBot.Main/Timers/DownloadClearJob.cs index c225f07b..5c18658f 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Timers/DownloadClearJob.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Timers/DownloadClearJob.cs @@ -1,5 +1,4 @@ using Quartz; -using System.Runtime.InteropServices; using TheresaBot.Main.Common; using TheresaBot.Main.Helper; using TheresaBot.Main.Reporter; @@ -36,11 +35,14 @@ private void ClearDownload() { try { - string path = FilePath.GetDownFileSavePath(); - if (Directory.Exists(path) == false) return; - DirectoryInfo directoryInfo = new DirectoryInfo(path); - directoryInfo.Delete(true); - LogHelper.Info("图片下载目录清理完毕..."); + lock (TimerManager.ClearLock) + { + string path = FilePath.GetDownFileSavePath(); + if (Directory.Exists(path) == false) return; + DirectoryInfo directoryInfo = new DirectoryInfo(path); + directoryInfo.Delete(true); + LogHelper.Info("图片下载目录清理完毕..."); + } } catch (Exception ex) { diff --git a/Theresa3rd-Bot/TheresaBot.Main/Timers/TempClearJob.cs b/Theresa3rd-Bot/TheresaBot.Main/Timers/TempClearJob.cs index f29c09b8..e1dec418 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Timers/TempClearJob.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Timers/TempClearJob.cs @@ -37,11 +37,14 @@ private void ClearTempDir() { try { - string path = FilePath.GetTempSavePath(); - if (Directory.Exists(path) == false) return; - DirectoryInfo directoryInfo = new DirectoryInfo(path); - directoryInfo.Delete(true); - LogHelper.Info("临时文件目录清理完毕..."); + lock (TimerManager.ClearLock) + { + string path = FilePath.GetTempSavePath(); + if (Directory.Exists(path) == false) return; + DirectoryInfo directoryInfo = new DirectoryInfo(path); + directoryInfo.Delete(true); + LogHelper.Info("临时文件目录清理完毕..."); + } } catch (Exception ex) { @@ -57,13 +60,16 @@ private void ClearUploadTemp() { try { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - ClearWindowsUploadTemp(); - } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + lock (TimerManager.ClearLock) { - ClearLinuxUploadTemp(); + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + ClearWindowsUploadTemp(); + } + if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + ClearLinuxUploadTemp(); + } } } catch (Exception ex) @@ -76,6 +82,7 @@ private void ClearUploadTemp() private void ClearWindowsUploadTemp() { string dirPath = System.IO.Path.GetTempPath(); + if (Directory.Exists(dirPath) == false) return; FileInfo[] fileList = FileHelper.SearchFiles(dirPath, "file-upload*.tmp"); if (fileList is null || fileList.Length == 0) return; foreach (var item in fileList) FileHelper.DeleteFile(item); @@ -87,8 +94,5 @@ private void ClearLinuxUploadTemp() } - - - } } diff --git a/Theresa3rd-Bot/TheresaBot.Main/Timers/TimerManager.cs b/Theresa3rd-Bot/TheresaBot.Main/Timers/TimerManager.cs index fb697b1f..fb3b0906 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/Timers/TimerManager.cs +++ b/Theresa3rd-Bot/TheresaBot.Main/Timers/TimerManager.cs @@ -10,6 +10,11 @@ namespace TheresaBot.Main.Timers { public static class TimerManager { + /// + /// 清理任务线程锁 + /// + internal static readonly object ClearLock = new object(); + /// /// 初始化定时提醒任务 /// diff --git a/Theresa3rd-Bot/TheresaBot.Main/botsettings.yml b/Theresa3rd-Bot/TheresaBot.Main/botsettings.yml index 79db11e1..a84875d7 100644 --- a/Theresa3rd-Bot/TheresaBot.Main/botsettings.yml +++ b/Theresa3rd-Bot/TheresaBot.Main/botsettings.yml @@ -1,12 +1,12 @@ General: #基础设置 Prefix: '#' #指令前缀 - DownloadPath: 'C:\BotImg\download' #下载文件的存放目录 + DownloadPath: 'BotImg/download' #下载文件的存放目录 DownPathCleanCron: '0 0 4 * * ?' #下载目录清理定时器,Cron表达式,空值表示不清理,格式:0 0 4 * * ? - DownErrorImgPath: 'C:\BotImg\face\downError.png' #图片下载失败时的替代图片 + DownErrorImgPath: 'BotImg/face/error.jpg' #图片下载失败时的替代图片 ErrorGroups: [284196392] #错误日志群,发生错误时会将日志发送到这些群 ErrorMsg: | #处理异常时返回的消息 出了点小问题,稍后再试吧 - [image:C:\BotImg\face\emmm.jpg] + [image:BotImg/face/emmm.jpg] DisableMsg: '该功能未开启' #功能未启用时返回的消息 NoPermissionsMsg: '该功能未授权' #功能未授权时返回的消息 ManagersRequiredMsg: '该功能需要管理员执行' #需要管理员权限时返回的消息 @@ -81,7 +81,7 @@ Welcome: - GroupId: 284196392 #群id(群号),这里只能填一个 Template: | #入群欢迎模版 欢迎萌新 - [image:C:\BotImg\face\welcome.png] + [image:BotImg/face/welcome.gif] 请认真阅读群内的相关公告 Reminder: #定时消息 @@ -95,7 +95,7 @@ Reminder: AtMembers: [] #艾特群员QQ号列表 Template: | #消息模版 今天是深渊结算的日子,旅行者打穿红莲了没? - [image:C:\BotImg\face\shenyuanjiesuan.png] + [image:BotImg/face/shenyuanjiesuan.png] Setu: #色图相关 GroupCD: 5 #共享CD(秒),使用命令后全群需要CD才能重新使用该功能 @@ -109,29 +109,29 @@ Setu: Pixiv: #Pixiv图床https://www.pixiv.net Enable: true #是否启用 - Commands: ['涩图'] #命令 + Commands: ['涩图','pixiv'] #命令 RandomMode: 1 #没有指定标签时获取图片的模式,1:随机一个RandomTags中标签进行搜索,2:随机获取一个已订阅画师的作品,3:随机获取一个关注中画师的作品,4:随机获取一个收藏中的作品 RandomTags: ['德丽莎','テレサ・アポカリプス'] #RandomMode=1时查找的标签 - Template: '本条数据来源于Pixiv,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回,私发需要给本bot发送任意消息开启临时会话哦~' + Template: '本条数据来源于Pixiv,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回' MaxScreen: 60 #根据标签搜索时,最多筛选N个作品,N个作品中不存在合格的涩图时,将返回NotFoundMsg MinBookmark: 900 #最低收藏数,用于判断涩图是否合格(标签搜索时适用) MinBookRate: 0.08 #最低收藏率,收藏数/浏览数(标签搜索时适用) Lolicon: #Lolicon图床 https://api.lolicon.app Enable: true #是否启用 - Commands: ['瑟图'] #命令 + Commands: ['瑟图','lolicon'] #命令 Template: | #消息模版,值为空时将使用默认模版 - 本条数据来源于Lolicon Api,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回,私发需要给本bot发送任意消息开启临时会话哦~ + 本条数据来源于Lolicon Api,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回 PixivId:{PixivId},标题:{IllustTitle},画师:{UserName},画师id:{UserId} 标签:{Tags},点击下方链接可以查看原图 {Urls} Lolisuki: #Lolisuki图床 https://lolisuki.cn Enable: true #是否启用 - Commands: ['setu'] #命令 + Commands: ['setu','lolisuki'] #命令 Level: '0-6' #Level范围,数字越大表示越涩,最小为0,最大为6,5-6为R18 Template: | #消息模版,值为空时将使用默认模版 - 本条数据来源于Lolisuki Api,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回,私发需要给本bot发送任意消息开启临时会话哦~ + 本条数据来源于Lolisuki Api,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回 PixivId:{PixivId},标题:{IllustTitle},画师:{UserName},画师id:{UserId},Level:{Level},分类:{Taste} 标签:{Tags},点击下方链接可以查看原图 {Urls} @@ -139,17 +139,16 @@ Setu: Local: #本地涩图 Enable: true #是否启用 Commands: ['本地涩图','群主珍藏'] #命令 - LocalPath: 'C:\BotImg\localSetu' #图片文件夹路径,该路径下需要包含存有涩图的子文件夹 + LocalPath: 'BotImg/localSetu' #图片文件夹路径,该路径下需要包含存有涩图的子文件夹 Template: | #消息模版,值为空时将使用默认模版 - 本条数据来源于本地图库,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回,私发需要给本bot发送任意消息开启临时会话哦~ + 本条数据来源于本地图库,{MemberCD}秒后再来哦,今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回 文件名:{FileName},大小:{SizeMB}MB Saucenao: #Saucenao以图搜图,查找原图功能 Enable: true #是否启用 - Commands: ['原图','搜图'] #命令 + Commands: ['原图','搜图','saucenao'] #命令 NotFoundMsg: | #找不到相应原图时返回的消息 - 找不到相似的图,请换一张图片重试。 - tips:如果通过截图获取搜索图片时,请只截取包含图片的部分,多余的色块只会影响搜索结果 + 找不到相似的图,请换一张完整的图片试试吧~ ProcessingMsg: '正在通过saucenao尝试搜索原图...' #开始查找前返回的消息 Template: '共找到 {MatchCount} 条匹配信息,相似度:{Similarity}%,来源:{SourceType},今天剩余使用次数{TodayLeft}次,本消息将在{RevokeInterval}秒后撤回,CD{MemberCD}秒' MemberCD: 30 #独立CD(秒),单个群员使用命令后需要等待的CD @@ -199,7 +198,7 @@ Subscribe: TimingSetu: #定时涩图,某个时间点自动发送一定数量的涩图 Enable: false #是否启用 - LocalPath: 'C:\BotImg\localSetu' #本地图片文件夹路径,图片需要分类放在子目录下,Source为0时可用 + LocalPath: 'BotImg/localSetu' #本地图片文件夹路径,图片需要分类放在子目录下,Source为0时可用 FromOneDir: false #true:从一个随机目录读取涩图,false:从不同的随机目录读取涩图,Source为0时可用 LolisukiLevel: '0-3' #Lolisuki的Level,Source为2时可用 Timers: #定时列表 @@ -218,7 +217,7 @@ PixivRanking: Enable: true #是否启用 ProcessingMsg: '正在获取榜单信息,需要亿点时间...' #开始执行前返回的消息 Template: '{Date}{Ranking}精选,数据缓存{CacheSeconds}秒' #消息模版 - MaxScan: 300 #每个排行榜最多扫描前N个作品 + MaxScan: 500 #每个排行榜最多扫描前N个作品 PreviewInPage: 30 #合成一览图中,每张一览图最多显示多少个作品 SortType: 2 #排序方式,0榜单排名,1收藏数排序,2收藏率排序,3点赞数排序,4点赞率排序 GroupCD: 300 #共享CD(秒),使用命令后全群需要CD才能重新使用该功能 diff --git a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/Session/MiraiSession.cs b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/Session/MiraiSession.cs index 645a2b2f..d6e54850 100644 --- a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/Session/MiraiSession.cs +++ b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/Session/MiraiSession.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using TheresaBot.Main.Model.Content; using TheresaBot.Main.Session; @@ -93,9 +94,10 @@ public override async Task SendGroupMergeAsync(long groupId, params List SendGroupMergeAsync(long groupId, List setuContents) { - if (setuContents.Count == 0) return 0; + var sendContents = setuContents.Where(o => o is not null).ToList(); + if (sendContents.Count == 0) return 0; List nodeList = new(); - foreach (var content in setuContents) + foreach (var content in sendContents) { List msgList = new List(); msgList.AddRange(await content.SetuInfos.ToMiraiMessageAsync()); diff --git a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj index 4731be18..e93dd700 100644 --- a/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj +++ b/Theresa3rd-Bot/TheresaBot.MiraiHttpApi/TheresaBot.MiraiHttpApi.csproj @@ -5,7 +5,7 @@ TheresaBot.MiraiHttpApi - 0.8.2 + 0.8.3 disable 3