Skip to content

Commit

Permalink
完善
Browse files Browse the repository at this point in the history
  • Loading branch information
ZJLLL114514 committed Jan 16, 2025
1 parent 2b8bb27 commit b891e1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/AIChatPlugin/AIChatPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@ private void OnPlayerLogout(PlayerLogoutEventArgs e)
{
playerContexts.Remove(playerId);
}
if (isProcessing.ContainsKey(playerId))
{
isProcessing.Remove(playerId);
}
}
private void BotReset(CommandArgs args)
{
Expand Down
8 changes: 4 additions & 4 deletions src/AIChatPlugin/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ internal class Utils
{
#region 问题审核
public static readonly Dictionary<int, List<string>> playerContexts = new();
public static readonly Dictionary<int, bool> isProcessing = new();
public static DateTime lastCmdTime = DateTime.MinValue;
public static bool isProcessing = false;
public static void ChatWithAI(TSPlayer player, string question)
{
var playerIndex = player.Index;
if (isProcessing.Values.Any(p => p))
if (isProcessing)
{
player.SendErrorMessage(GetString("[i:1344]有其他玩家在询问问题,请排队[i:1344]"));
return;
Expand All @@ -27,7 +27,7 @@ public static void ChatWithAI(TSPlayer player, string question)
}
lastCmdTime = DateTime.Now;
player.SendSuccessMessage(GetString("[i:1344]正在处理您的请求,请稍候...[i:1344]"));
isProcessing[playerIndex] = true;
isProcessing = true;
Task.Run(async () =>
{
try
Expand All @@ -44,7 +44,7 @@ public static void ChatWithAI(TSPlayer player, string question)
}
finally
{
isProcessing[playerIndex] = false;
isProcessing = false;
}
});
}
Expand Down

0 comments on commit b891e1a

Please sign in to comment.