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:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user