Updated GetFriends implementation

This commit is contained in:
Chomp
2025-01-14 16:16:57 +00:00
parent b2d7943d9d
commit 34dcd2283e
3 changed files with 34 additions and 12 deletions
+24 -1
View File
@@ -5,6 +5,7 @@ using Core.Models.Eft.Dialog;
using Core.Models.Eft.HttpResponse;
using Core.Models.Eft.Profile;
using Core.Models.Enums;
using Core.Models.Spt.Config;
using Core.Servers;
namespace Core.Controllers;
@@ -14,17 +15,23 @@ public class DialogueController
{
private readonly DialogueHelper _dialogueHelper;
private readonly ProfileHelper _profileHelper;
private readonly ConfigServer _configServer;
private readonly SaveServer _saveServer;
private readonly List<IDialogueChatBot> _dialogueChatBots;
private readonly CoreConfig _coreConfig;
public DialogueController(
DialogueHelper dialogueHelper,
ProfileHelper profileHelper,
ConfigServer configServer,
SaveServer saveServer)
{
_dialogueHelper = dialogueHelper;
_profileHelper = profileHelper;
_configServer = configServer;
_saveServer = saveServer;
_coreConfig = _configServer.GetConfig<CoreConfig>(ConfigTypes.CORE);
}
/// <summary>
@@ -54,7 +61,7 @@ public class DialogueController
public GetFriendListDataResponse GetFriendList(string sessionId)
{
// Add all chatbots to the friends list
var friends = _dialogueChatBots.Select((bot) => bot.GetChatBot()).ToList();
var friends = GetActiveChatBots();
// Add any friends the user has after the chatbots
var profile = _profileHelper.GetFullProfile(sessionId);
@@ -82,6 +89,22 @@ public class DialogueController
};
}
private List<UserDialogInfo> GetActiveChatBots()
{
var activeBots = new List<UserDialogInfo>();
var chatBotConfig = _coreConfig.Features.ChatbotFeatures;
foreach (var bot in _dialogueChatBots)
{
var botData = bot.GetChatBot();
if (chatBotConfig.EnabledBots.ContainsKey(botData.Id)) {
activeBots.Add(botData);
}
}
return activeBots;
}
/// <summary>
/// Handle client/mail/dialog/list
/// Create array holding trader dialogs and mail interactions with player