diff --git a/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs b/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs index 89d3b5e7..cd89d259 100644 --- a/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs +++ b/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs @@ -8,6 +8,7 @@ using Core.Models.Utils; using Core.Servers; using Core.Services; using Core.Utils; +using Core.Helpers.Dialogue.SptMessageHandlers; namespace Core.Helpers.Dialogue; @@ -18,15 +19,21 @@ public class SptDialogueChatBot( IEnumerable _chatCommands, ConfigServer _configServer, ProfileHelper _profileHelper, - RandomUtil _randomUtil, - SeasonalEventService _seasonalEventService, - GiftService _giftService, - LocalisationService _localisationService + IEnumerable chatMessageHandlers ) : IDialogueChatBot { + protected IEnumerable _chatMessageHandlers = ChatMessageHandlerSetup(chatMessageHandlers); + + private static List ChatMessageHandlerSetup(IEnumerable components) + { + var chatMessageHandlers = components.ToList(); + chatMessageHandlers.Sort((a, b) => a.GetPriority() - b.GetPriority()); + + return chatMessageHandlers; + } + protected CoreConfig _coreConfig = _configServer.GetConfig(); - protected WeatherConfig _weatherConfig = _configServer.GetConfig(); - protected List _listOfMessages = ["hello", "hi", "sup", "yo", "hey"]; + public UserDialogInfo GetChatBot() { @@ -48,190 +55,10 @@ public class SptDialogueChatBot( public string? HandleMessage(string sessionId, SendMessageRequest request) { var sender = _profileHelper.GetPmcProfile(sessionId); - var sptFriendUser = GetChatBot(); - var requestInput = request.Text.ToLower(); - // only check if entered text is gift code when feature enabled - if (_coreConfig.Features.ChatbotFeatures.SptFriendGiftsEnabled) { - var giftSent = _giftService.SendGiftToPlayer(sessionId, request.Text); - if (giftSent == GiftSentResult.SUCCESS) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - "Hey! you got the right code!", - "A secret code, how exciting!", - "You found a gift code!", - "A gift code! incredible", - "A gift! what could it be!", - ]), - [], - null - ); - - return null; - } - - if (giftSent == GiftSentResult.FAILED_GIFT_ALREADY_RECEIVED) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue(["Looks like you already used that code", "You already have that!!"]), - [], - null - ); - - return null; - } - } - - if (requestInput.Contains("love you")) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - "That's quite forward but i love you too in a purely chatbot-human way", - "I love you too buddy :3!", - "uwu", - $"love you too {sender?.Info?.Nickname}", - ]), - [], - null - ); - } - - if (requestInput == "spt") { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue(["Its me!!", "spt? i've heard of that project"]), - [], - null - ); - } - - if (requestInput == "fish") { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue(["blub"]), - [], - null - ); - } - - if (_listOfMessages.Contains(requestInput)) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - "Howdy", - "Hi", - "Greetings", - "Hello", - "bonjor", - "Yo", - "Sup", - "Heyyyyy", - "Hey there", - $"Hello {sender?.Info?.Nickname}", - ]), - [], null - ); - } - - if (requestInput == "nikita") { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - "I know that guy!", - "Cool guy, he made EFT!", - "Legend", - "Remember when he said webel-webel-webel-webel, classic Nikita moment", - ]), [], null - ); - } - - if (requestInput == "are you a bot") { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue(["beep boop", "**sad boop**", "probably", "sometimes", "yeah lol"]), - [], null - ); - } - - if (requestInput == "itsonlysnowalan") { - _weatherConfig.OverrideSeason = Season.WINTER; - - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([_localisationService.GetText("chatbot-snow_enabled")]), [], null - ); - } - - if (requestInput == "givemesunshine") { - _weatherConfig.OverrideSeason = Season.SUMMER; - - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([_localisationService.GetText("chatbot-summer_enabled")]), [], null - ); - } - - if (requestInput == "veryspooky") { - var enableEventResult = _seasonalEventService.ForceSeasonalEvent(SeasonalEventType.Halloween); - if (enableEventResult) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - _localisationService.GetText("chatbot-forced_event_enabled", SeasonalEventType.Halloween) - ]), [], null - ); - } - } - - if (requestInput == "hohoho") { - var enableEventResult = _seasonalEventService.ForceSeasonalEvent(SeasonalEventType.Christmas); - if (enableEventResult) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - _localisationService.GetText("chatbot-forced_event_enabled", SeasonalEventType.Christmas) - ]), [], null - ); - } - } - - if (requestInput == "givemespace") { - var stashRowGiftId = "StashRows"; - var maxGiftsToSendCount = _coreConfig.Features.ChatbotFeatures.CommandUseLimits[stashRowGiftId] ?? 5; - if (_profileHelper.PlayerHasRecievedMaxNumberOfGift(sessionId, stashRowGiftId, maxGiftsToSendCount)) { - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _localisationService.GetText("chatbot-cannot_accept_any_more_of_gift"), [], null - ); - } else { - _profileHelper.AddStashRowsBonusToProfile(sessionId, 2); - - _mailSendService.SendUserMessageToPlayer( - sessionId, - sptFriendUser, - _randomUtil.GetArrayValue([ - _localisationService.GetText("chatbot-added_stash_rows_please_restart"), - ]), [], null - ); - - _profileHelper.FlagGiftReceivedInProfile(sessionId, stashRowGiftId, maxGiftsToSendCount); - } - } + _chatMessageHandlers.FirstOrDefault((v) => v.CanHandle(request.Text)) + .Process(sessionId, sptFriendUser, sender); return request.DialogId; } diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/AreYouABotMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/AreYouABotMessageHandler.cs new file mode 100644 index 00000000..7aa97ad7 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/AreYouABotMessageHandler.cs @@ -0,0 +1,34 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class AreYouABotMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil) : IChatMessageHandler + { + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "are you a bot"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue(["beep boop", "**sad boop**", "probably", "sometimes", "yeah lol"]), + [], null + ); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/FishMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/FishMessageHandler.cs new file mode 100644 index 00000000..d1b5ed84 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/FishMessageHandler.cs @@ -0,0 +1,32 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers; + +[Injectable] +public class FishMessageHandler( + MailSendService _mailSendService) : IChatMessageHandler +{ + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "fish"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + "blub", + [], + null + ); + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceChristmasMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceChristmasMessageHandler.cs new file mode 100644 index 00000000..50c486e8 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceChristmasMessageHandler.cs @@ -0,0 +1,42 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class ForceChristmasMessageHandler( + LocalisationService _localisationService, + MailSendService _mailSendService, + RandomUtil _randomUtil, + SeasonalEventService _seasonalEventService) : IChatMessageHandler + { + public int GetPriority() + { + return 99; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "hohoho"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + var enableEventResult = _seasonalEventService.ForceSeasonalEvent(SeasonalEventType.Christmas); + if (enableEventResult) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + _localisationService.GetText("chatbot-forced_event_enabled", SeasonalEventType.Christmas) + ]), [], null + ); + } + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceHalloweenMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceHalloweenMessageHandler.cs new file mode 100644 index 00000000..4240b569 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceHalloweenMessageHandler.cs @@ -0,0 +1,44 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class ForceHalloweenMessageHandler( + LocalisationService _localisationService, + MailSendService _mailSendService, + RandomUtil _randomUtil, + SeasonalEventService _seasonalEventService) : IChatMessageHandler + { + public int GetPriority() + { + return 99; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "veryspooky"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + var enableEventResult = _seasonalEventService.ForceSeasonalEvent(SeasonalEventType.Halloween); + if (enableEventResult) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + _localisationService.GetText("chatbot-forced_event_enabled", SeasonalEventType.Halloween) + ]), + [], + null + ); + } + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSnowMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSnowMessageHandler.cs new file mode 100644 index 00000000..23658c5a --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSnowMessageHandler.cs @@ -0,0 +1,44 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class ForceSnowMessageHandler( + LocalisationService _localisationService, + MailSendService _mailSendService, + RandomUtil _randomUtil, + ConfigServer _configServer) : IChatMessageHandler + { + private WeatherConfig _weatherConfig = _configServer.GetConfig(); + + public int GetPriority() + { + return 99; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "itsonlysnowalan"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _weatherConfig.OverrideSeason = Season.WINTER; + + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([_localisationService.GetText("chatbot-snow_enabled")]), + [], + null + ); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSummerMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSummerMessageHandler.cs new file mode 100644 index 00000000..b4471670 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/ForceSummerMessageHandler.cs @@ -0,0 +1,44 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class ForceSummerMessageHandler( + LocalisationService _localisationService, + MailSendService _mailSendService, + RandomUtil _randomUtil, + ConfigServer _configServer) : IChatMessageHandler + { + private WeatherConfig _weatherConfig = _configServer.GetConfig(); + + public int GetPriority() + { + return 99; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "givemesunshine"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _weatherConfig.OverrideSeason = Season.SUMMER; + + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([_localisationService.GetText("chatbot-summer_enabled")]), + [], + null + ); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/GiveMeSpaceMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/GiveMeSpaceMessageHandler.cs new file mode 100644 index 00000000..1df515d9 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/GiveMeSpaceMessageHandler.cs @@ -0,0 +1,58 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers; + +[Injectable] +public class GiveMeSpaceMessageHandler( + ProfileHelper _profileHelper, + LocalisationService _localisationService, + MailSendService _mailSendService, + RandomUtil _randomUtil, + ConfigServer _configServer) : IChatMessageHandler +{ + private CoreConfig _coreConfig = _configServer.GetConfig(); + + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "givemespace"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + const string stashRowGiftId = "StashRows"; + var maxGiftsToSendCount = _coreConfig.Features.ChatbotFeatures.CommandUseLimits[stashRowGiftId] ?? 5; + if (_profileHelper.PlayerHasRecievedMaxNumberOfGift(sessionId, stashRowGiftId, maxGiftsToSendCount)) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _localisationService.GetText("chatbot-cannot_accept_any_more_of_gift"), [], null + ); + } + else + { + _profileHelper.AddStashRowsBonusToProfile(sessionId, 2); + + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + _localisationService.GetText("chatbot-added_stash_rows_please_restart"), + ]), [], null + ); + + _profileHelper.FlagGiftReceivedInProfile(sessionId, stashRowGiftId, maxGiftsToSendCount); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/HelloMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/HelloMessageHandler.cs new file mode 100644 index 00000000..a8cd23de --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/HelloMessageHandler.cs @@ -0,0 +1,48 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class HelloMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil) : IChatMessageHandler + { + protected List _listOfMessages = ["hello", "hi", "sup", "yo", "hey", "bonjour"]; + + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return _listOfMessages.Contains(message, StringComparer.OrdinalIgnoreCase); + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + "Howdy", + "Hi", + "Greetings", + "Hello", + "Bonjor", + "Yo", + "Sup", + "Heyyyyy", + "Hey there", + "OH its you", + $"Hello {sender?.Info?.Nickname}", + ]), + [], null + ); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/IChatMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/IChatMessageHandler.cs new file mode 100644 index 00000000..8287c15b --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/IChatMessageHandler.cs @@ -0,0 +1,13 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; + +namespace Core.Helpers.Dialogue.SptMessageHandlers; + +public interface IChatMessageHandler +{ + // Lower = More priority + int GetPriority(); + + public abstract bool CanHandle(string message); + public abstract void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender); +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/LoveYouChatMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/LoveYouChatMessageHandler.cs new file mode 100644 index 00000000..587d7168 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/LoveYouChatMessageHandler.cs @@ -0,0 +1,40 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers; + +[Injectable] +public class LoveYouChatMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil +) : IChatMessageHandler +{ + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "love you"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + "That's quite forward but i love you too in a purely chatbot-human way", + "I love you too buddy :3!", + "uwu", + $"love you too {sender?.Info?.Nickname}", + ]), + [], + null + ); + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/NikitaMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/NikitaMessageHandler.cs new file mode 100644 index 00000000..250a5327 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/NikitaMessageHandler.cs @@ -0,0 +1,39 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class NikitaMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil) : IChatMessageHandler + { + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "nikita"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + "I know that guy!", + "Cool guy, he made EFT!", + "Legend", + "The mastermind of my suffering", + "Remember when he said webel-webel-webel-webel, classic Nikita moment", + ]), [], null + ); + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SendGiftMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SendGiftMessageHandler.cs new file mode 100644 index 00000000..52dc2512 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SendGiftMessageHandler.cs @@ -0,0 +1,71 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers +{ + [Injectable] + public class SendGiftMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil, + GiftService _giftService, + ConfigServer _configServer) : IChatMessageHandler + { + private CoreConfig _coreConfig = _configServer.GetConfig(); + private string commandSent = string.Empty; + + public int GetPriority() + { + return 1; + } + + public bool CanHandle(string message) + { + return _giftService.GiftExists(message.ToLower()); + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + // Gifts may be disabled via config + if (!_coreConfig.Features.ChatbotFeatures.SptFriendGiftsEnabled) + { + return; + } + + var giftSent = _giftService.SendGiftToPlayer(sessionId, commandSent); + switch (giftSent) + { + case GiftSentResult.SUCCESS: + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue([ + "Hey! you got the right code!", + "A secret code, how exciting!", + "You found a gift code!", + "A gift code! incredible", + "A gift! what could it be!"]), + [], + null + ); + + return; + case GiftSentResult.FAILED_GIFT_ALREADY_RECEIVED: + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue(["Looks like you already used that code", "You already have that!!"]), + [], + null + ); + + return; + } + } + } +} diff --git a/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SptMessageHandler.cs b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SptMessageHandler.cs new file mode 100644 index 00000000..fb8ad3f3 --- /dev/null +++ b/Libraries/Core/Helpers/Dialogue/SptMessageHandlers/SptMessageHandler.cs @@ -0,0 +1,34 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Profile; +using Core.Services; +using Core.Utils; +using SptCommon.Annotations; + +namespace Core.Helpers.Dialogue.SptMessageHandlers; + +[Injectable] +public class SptMessageHandler( + MailSendService _mailSendService, + RandomUtil _randomUtil) : IChatMessageHandler +{ + public int GetPriority() + { + return 100; + } + + public bool CanHandle(string message) + { + return message.ToLower() == "spt"; + } + + public void Process(string sessionId, UserDialogInfo sptFriendUser, PmcData sender) + { + _mailSendService.SendUserMessageToPlayer( + sessionId, + sptFriendUser, + _randomUtil.GetArrayValue(["Its me!!", "spt? i've heard of that project"]), + [], + null + ); + } +}