Chatbot async improvements (#446)

* Add better chatbot handling by making them asynchronous

Removes the need for having RunInTimespan as await Task.Delay now can handle this

* Remove now unused classes

* Handle commando's commands with ValueTask

* Set values as not nullable, client sends all of these
This commit is contained in:
Jesse
2025-07-04 19:04:37 +02:00
committed by GitHub
parent 762d42c009
commit b6692fead4
14 changed files with 90 additions and 128 deletions
@@ -538,15 +538,22 @@ public class DialogueController(
/// <param name="sessionId">Session/Player id</param>
/// <param name="request"></param>
/// <returns></returns>
public virtual string SendMessage(string sessionId, SendMessageRequest request)
public virtual async ValueTask<string> SendMessage(string sessionId, SendMessageRequest request)
{
_mailSendService.SendPlayerMessageToNpc(sessionId, request.DialogId!, request.Text!);
return (
_dialogueChatBots
.FirstOrDefault(cb => cb.GetChatBot().Id == request.DialogId)
?.HandleMessage(sessionId, request) ?? request.DialogId
) ?? string.Empty;
var chatBot = _dialogueChatBots.FirstOrDefault(cb =>
cb.GetChatBot().Id == request.DialogId
);
if (chatBot is not null)
{
return await chatBot.HandleMessage(sessionId, request);
}
else
{
return string.Empty;
}
}
/// <summary>