Skip to content

Commit

Permalink
代码整理
Browse files Browse the repository at this point in the history
  • Loading branch information
GardenHamster committed Jan 2, 2024
1 parent e7c4820 commit 6538264
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Handler/BaseHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public async Task<bool> CheckSuperManagersAsync(PrivateCommand command)
{
if (command.MemberId.IsSuperManager() == false)
{
await command.ReplyFriendTemplateAsync(BotConfig.GeneralConfig.ManagersRequiredMsg, "该功能需要管理员执行");
await command.ReplyPrivateTemplateAsync(BotConfig.GeneralConfig.ManagersRequiredMsg, "该功能需要管理员执行");
return false;
}
return true;
Expand Down
12 changes: 6 additions & 6 deletions Theresa3rd-Bot/TheresaBot.Main/Handler/CookieHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ public async Task UpdatePixivCookieAsync(PrivateCommand command)
var cookie = command.KeyWord;
if (string.IsNullOrWhiteSpace(cookie))
{
await command.ReplyFriendMessageAsync($"未检测到Cookie");
await command.ReplyPrivateMessageAsync($"未检测到Cookie");
return;
}
var website = websiteService.UpdatePixivCookie(cookie);
WebsiteDatas.LoadWebsite();
var expireDate = website.CookieExpireDate.ToSimpleString();
await command.ReplyFriendMessageAsync($"Cookie更新完毕,过期时间为:{expireDate}");
await command.ReplyPrivateMessageAsync($"Cookie更新完毕,过期时间为:{expireDate}");
}
catch (HandleException ex)
{
await command.ReplyFriendMessageAsync(ex.RemindMessage);
await command.ReplyPrivateMessageAsync(ex.RemindMessage);
}
catch (Exception ex)
{
Expand All @@ -61,17 +61,17 @@ public async Task UpdateSaucenaoCookieAsync(PrivateCommand command)
var cookie = command.KeyWord;
if (string.IsNullOrWhiteSpace(cookie))
{
await command.ReplyFriendMessageAsync($"未检测到Cookie");
await command.ReplyPrivateMessageAsync($"未检测到Cookie");
return;
}
var website = websiteService.UpdateSaucenaoCookie(cookie);
WebsiteDatas.LoadWebsite();
var expireDate = website.CookieExpireDate.ToSimpleString();
await command.ReplyFriendMessageAsync($"Cookie更新完毕,过期时间为:{expireDate}");
await command.ReplyPrivateMessageAsync($"Cookie更新完毕,过期时间为:{expireDate}");
}
catch (HandleException ex)
{
await command.ReplyFriendMessageAsync(ex.RemindMessage);
await command.ReplyPrivateMessageAsync(ex.RemindMessage);
}
catch (Exception ex)
{
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Handler/LocalSetuHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public async Task LocalSearchAsync(GroupCommand command)
if (BotConfig.SetuConfig.SendPrivate)
{
await Task.Delay(1000);
Task sendTempTask = command.SendTempSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
Task sendTempTask = command.SendPrivateSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
}
CoolingCache.SetMemberSetuCooling(command.GroupId, command.MemberId);
}
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Handler/LoliconHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public async Task LoliconSearchAsync(GroupCommand command)
if (BotConfig.SetuConfig.SendPrivate)
{
await Task.Delay(1000);
Task sendTempTask = command.SendTempSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
Task sendTempTask = command.SendPrivateSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
}

CoolingCache.SetMemberSetuCooling(command.GroupId, command.MemberId);
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Handler/LolisukiHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public async Task LolisukiSearchAsync(GroupCommand command)
if (BotConfig.SetuConfig.SendPrivate)
{
await Task.Delay(1000);
Task sendTempTask = command.SendTempSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
Task sendTempTask = command.SendPrivateSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
}

CoolingCache.SetMemberSetuCooling(command.GroupId, command.MemberId);
Expand Down
2 changes: 1 addition & 1 deletion Theresa3rd-Bot/TheresaBot.Main/Handler/PixivHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public async Task PixivSearchAsync(GroupCommand command)
if (BotConfig.SetuConfig.SendPrivate)
{
await Task.Delay(1000);
Task sendTempTask = command.SendTempSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
Task sendTempTask = command.SendPrivateSetuAsync(setuContent, BotConfig.PixivConfig.SendImgBehind);
}

CoolingCache.SetMemberSetuCooling(command.GroupId, command.MemberId);//进入CD状态
Expand Down
4 changes: 2 additions & 2 deletions Theresa3rd-Bot/TheresaBot.Main/Handler/SaucenaoHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private async Task ReplyAndRevoke(GroupCommand command, List<BaseContent> conten
if (BotConfig.SaucenaoConfig.SendPrivate)
{
await Task.Delay(1000);
await command.SendTempMessageAsync(contentList);
await command.SendPrivateMessageAsync(contentList);
}
}

Expand All @@ -269,7 +269,7 @@ private async Task ReplyAndRevoke(GroupCommand command, List<SetuContent> setuCo
if (BotConfig.SaucenaoConfig.SendPrivate)
{
await Task.Delay(1000);
await command.SendTempSetuAsync(setuContents);
await command.SendPrivateSetuAsync(setuContents);
}
}

Expand Down
14 changes: 7 additions & 7 deletions Theresa3rd-Bot/TheresaBot.Main/Handler/UndercoverHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public async Task SendPrivateWords(GroupCommand command)
var contents = new List<BaseContent> {
new PlainContent(player.GetWordMessage(ucConfig.SendIdentity))
};
await command.SendTempMessageAsync(contents);
await command.SendPrivateMessageAsync(contents);
await Task.Delay(1000);
await command.ReplyGroupMessageWithQuoteAsync("词条已私发,请查看私聊消息");
}
Expand All @@ -104,19 +104,19 @@ public async Task CreateWords(PrivateCommand command)
var limitCount = BotConfig.GameConfig.Undercover.AddWordLimits;
if (isManager == false && limitCount <= 0)
{
await command.ReplyFriendMessageAsync($"超级管理员已关闭添加词条功能,请联系超级管理员~");
await command.ReplyPrivateMessageAsync($"超级管理员已关闭添加词条功能,请联系超级管理员~");
return;
}
var unauthCount = ucWordService.GetUnauthorizedCount(command.MemberId);
if (isManager == false && unauthCount >= limitCount)
{
await command.ReplyFriendMessageAsync($"已添加{unauthCount}个未经审核的词条,请等待超级管理员审核后再继续添加~");
await command.ReplyPrivateMessageAsync($"已添加{unauthCount}个未经审核的词条,请等待超级管理员审核后再继续添加~");
return;
}
var newWords = await AskNewWords(command);
if (isManager == false && unauthCount + newWords.Count > limitCount)
{
await command.ReplyFriendMessageAsync($"非超级管理员限制添加词条个数为{limitCount}个,剩余可添加词条{limitCount - unauthCount}个,等待管理员审核后可以添加更多词条");
await command.ReplyPrivateMessageAsync($"非超级管理员限制添加词条个数为{limitCount}个,剩余可添加词条{limitCount - unauthCount}个,等待管理员审核后可以添加更多词条");
return;
}
foreach (var item in newWords)
Expand All @@ -126,16 +126,16 @@ public async Task CreateWords(PrivateCommand command)
}
if (isManager)
{
await command.ReplyFriendMessageAsync("添加完毕~");
await command.ReplyPrivateMessageAsync("添加完毕~");
}
else
{
await command.ReplyFriendMessageAsync("添加完毕,请等待超级管理员审核~");
await command.ReplyPrivateMessageAsync("添加完毕,请等待超级管理员审核~");
}
}
catch (ProcessException ex)
{
await command.ReplyFriendMessageAsync(ex.RemindMessage);
await command.ReplyPrivateMessageAsync(ex.RemindMessage);
}
catch (Exception ex)
{
Expand Down
20 changes: 10 additions & 10 deletions Theresa3rd-Bot/TheresaBot.Main/Helper/CommandHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ public static async Task ReplyProcessingMessageAsync(this GroupCommand command,
/// <param name="command"></param>
/// <param name="setuContents"></param>
/// <returns></returns>
public static async Task<BaseResult> SendTempSetuAsync(this GroupCommand command, List<SetuContent> setuContents)
public static async Task<BaseResult> SendPrivateSetuAsync(this GroupCommand command, List<SetuContent> setuContents)
{
List<BaseContent> contentList = setuContents.ToBaseContent().SetDefaultImage();
return await command.SendTempMessageAsync(contentList);
return await command.SendPrivateMessageAsync(contentList);
}

/// <summary>
Expand All @@ -175,22 +175,22 @@ public static async Task<BaseResult> SendTempSetuAsync(this GroupCommand command
/// <param name="setuContent"></param>
/// <param name="sendImgBehind"></param>
/// <returns></returns>
public static async Task<BaseResult[]> SendTempSetuAsync(this GroupCommand command, SetuContent setuContent, bool sendImgBehind)
public static async Task<BaseResult[]> SendPrivateSetuAsync(this GroupCommand command, SetuContent setuContent, bool sendImgBehind)
{
List<BaseResult> results = new List<BaseResult>();
List<BaseContent> msgContents = setuContent.SetuInfos ?? new();
List<BaseContent> imgContents = setuContent.SetuImages.ToBaseContent().SetDefaultImage().ToList();

if (sendImgBehind)
{
results.Add(await command.SendTempMessageAsync(msgContents));
results.Add(await command.SendPrivateMessageAsync(msgContents));
await Task.Delay(1000);
results.Add(await command.SendTempMessageAsync(imgContents));
results.Add(await command.SendPrivateMessageAsync(imgContents));
}
else
{
List<BaseContent> contentList = msgContents.Concat(imgContents).ToList();
results.Add(await command.SendTempMessageAsync(contentList));
results.Add(await command.SendPrivateMessageAsync(contentList));
}

return results.ToArray();
Expand Down Expand Up @@ -310,7 +310,7 @@ public static async Task<BaseResult> ReplyGroupTemplateWithQuoteAsync(this Group
/// <param name="template"></param>
/// <param name="defaultmsg"></param>
/// <returns></returns>
public static async Task<BaseResult> ReplyFriendTemplateAsync(this PrivateCommand command, string template, string defaultmsg)
public static async Task<BaseResult> ReplyPrivateTemplateAsync(this PrivateCommand command, string template, string defaultmsg)
{
template = template?.Trim()?.TrimLine();
if (string.IsNullOrWhiteSpace(template)) template = defaultmsg;
Expand Down Expand Up @@ -368,7 +368,7 @@ public static async Task<BaseResult> ReplyGroupMessageWithAtAsync(this GroupComm
/// <param name="command"></param>
/// <param name="contents"></param>
/// <returns></returns>
public static async Task<BaseResult> SendTempMessageAsync(this GroupCommand command, List<BaseContent> contents)
public static async Task<BaseResult> SendPrivateMessageAsync(this GroupCommand command, List<BaseContent> contents)
{
return await command.Session.SendTempMessageAsync(command.GroupId, command.MemberId, contents);
}
Expand All @@ -379,7 +379,7 @@ public static async Task<BaseResult> SendTempMessageAsync(this GroupCommand comm
/// <param name="command"></param>
/// <param name="message"></param>
/// <returns></returns>
public static async Task<BaseResult> ReplyFriendMessageAsync(this PrivateCommand command, string message)
public static async Task<BaseResult> ReplyPrivateMessageAsync(this PrivateCommand command, string message)
{
return await command.Session.SendFriendMessageAsync(command.MemberId, message);
}
Expand All @@ -390,7 +390,7 @@ public static async Task<BaseResult> ReplyFriendMessageAsync(this PrivateCommand
/// <param name="command"></param>
/// <param name="contents"></param>
/// <returns></returns>
public static async Task<BaseResult> ReplyFriendMessageAsync(this PrivateCommand command, List<BaseContent> contents)
public static async Task<BaseResult> ReplyPrivateMessageAsync(this PrivateCommand command, List<BaseContent> contents)
{
return await command.Session.SendFriendMessageAsync(command.MemberId, contents);
}
Expand Down
6 changes: 3 additions & 3 deletions Theresa3rd-Bot/TheresaBot.Main/Model/Process/FriendStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ public FriendStep(PrivateCommand command, string question, int waitSecond, Func<

public override async Task SendQuestion()
{
await FriendCommand.ReplyFriendMessageAsync(Question);
await FriendCommand.ReplyPrivateMessageAsync(Question);
}

public override async Task ReplyError(BaseRelay relay, ProcessException ex)
{
await FriendCommand.ReplyFriendMessageAsync(ex.RemindMessage);
await FriendCommand.ReplyPrivateMessageAsync(ex.RemindMessage);
}

public override async Task<bool> CheckInputAsync(BaseRelay relay)
Expand All @@ -57,7 +57,7 @@ public override async Task<bool> CheckInputAsync(BaseRelay relay)
}
catch (ProcessException ex)
{
await FriendCommand.ReplyFriendMessageAsync(ex.RemindMessage);
await FriendCommand.ReplyPrivateMessageAsync(ex.RemindMessage);
return false;
}
}
Expand Down

0 comments on commit 6538264

Please sign in to comment.