Skip to content

Commit

Permalink
Merge branch 'v0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
GardenHamster committed Jun 3, 2022
2 parents 0d6f30a + 0169fb9 commit 3712a82
Show file tree
Hide file tree
Showing 11 changed files with 509 additions and 413 deletions.
24 changes: 17 additions & 7 deletions Theresa3rd-Bot/Business/LoliconBusiness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public async Task sendGeneralLoliconImageAsync(IMiraiHttpSession session, IGroup
{
try
{
long memberId = args.Sender.Id;
long groupId = args.Sender.Group.Id;
DateTime startDateTime = DateTime.Now;
CoolingCache.SetHanding(args.Sender.Group.Id, args.Sender.Id);//请求处理中
CoolingCache.SetHanding(groupId, memberId);//请求处理中

if (string.IsNullOrWhiteSpace(BotConfig.SetuConfig.Lolicon.ProcessingMsg) == false)
{
Expand Down Expand Up @@ -60,12 +62,12 @@ public async Task sendGeneralLoliconImageAsync(IMiraiHttpSession session, IGroup
if (string.IsNullOrWhiteSpace(template))
{
StringBuilder warnBuilder = new StringBuilder();
if (BotConfig.PermissionsConfig.SetuNoneCDGroups.Contains(args.Sender.Group.Id) == false)
if (BotConfig.PermissionsConfig.SetuNoneCDGroups.Contains(groupId) == false)
{
if (warnBuilder.Length > 0) warnBuilder.Append("");
warnBuilder.Append($"{BotConfig.SetuConfig.MemberCD}秒后再来哦");
}
if (BotConfig.PermissionsConfig.SetuLimitlessGroups.Contains(args.Sender.Group.Id) == false)
if (BotConfig.PermissionsConfig.SetuLimitlessGroups.Contains(groupId) == false)
{
if (warnBuilder.Length > 0) warnBuilder.Append("");
warnBuilder.Append($"今天剩余使用次数{todayLeftCount}");
Expand Down Expand Up @@ -96,6 +98,10 @@ public async Task sendGeneralLoliconImageAsync(IMiraiHttpSession session, IGroup
{
groupList.Add((IChatMessage)await session.UploadPictureAsync(UploadTarget.Group, fileInfo.FullName));
}
else if (loliconData.isR18() && groupId.IsShowR18Img())
{
groupList.Add((IChatMessage)await session.UploadPictureAsync(UploadTarget.Group, fileInfo.FullName));
}
groupMsgId = await session.SendMessageWithAtAsync(args, groupList);
await Task.Delay(1000);
}
Expand All @@ -116,11 +122,15 @@ public async Task sendGeneralLoliconImageAsync(IMiraiHttpSession session, IGroup
{
memberList.AddRange(await session.SplitToChainAsync(BotConfig.GeneralConfig.DownErrorImg, UploadTarget.Temp));
}
if (loliconData.isR18() == false && fileInfo != null)
else if (loliconData.isR18() == false)
{
memberList.Add((IChatMessage)await session.UploadPictureAsync(UploadTarget.Temp, fileInfo.FullName));
}
else if (loliconData.isR18() && groupId.IsShowR18Img())
{
memberList.Add((IChatMessage)await session.UploadPictureAsync(UploadTarget.Temp, fileInfo.FullName));
}
await session.SendTempMessageAsync(args.Sender.Id, args.Sender.Group.Id, memberList.ToArray());
await session.SendTempMessageAsync(memberId, groupId, memberList.ToArray());
await Task.Delay(1000);
}
catch (Exception ex)
Expand All @@ -130,7 +140,7 @@ public async Task sendGeneralLoliconImageAsync(IMiraiHttpSession session, IGroup
}

//进入CD状态
CoolingCache.SetMemberSTCooling(args.Sender.Group.Id, args.Sender.Id);
CoolingCache.SetMemberSTCooling(groupId, memberId);
if (groupMsgId == 0 || BotConfig.SetuConfig.RevokeInterval == 0) return;

try
Expand Down Expand Up @@ -215,7 +225,7 @@ public async Task<FileInfo> downImgAsync(LoliconDataV2 loliconData)
string fullFileName = $"{loliconData.pid}.jpg";
string fullImageSavePath = Path.Combine(FilePath.getDownImgSavePath(), fullFileName);
string imgUrl = loliconData.urls.original;
if (BotConfig.GeneralConfig.DownWithProxy)
if (BotConfig.GeneralConfig.DownWithProxy || BotConfig.GeneralConfig.PixivFreeProxy)
{
imgUrl = getProxyUrl(imgUrl);
return await HttpHelper.DownFileAsync(imgUrl, fullImageSavePath);
Expand Down
Loading

0 comments on commit 3712a82

Please sign in to comment.