diff --git a/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs b/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs index cbaa99e0..1d82345d 100644 --- a/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs +++ b/Libraries/Core/Helpers/Dialogue/SptDialogueChatBot.cs @@ -23,10 +23,8 @@ public class SptDialogueChatBot( ) : IDialogueChatBot { protected IEnumerable _chatMessageHandlers = ChatMessageHandlerSetup(chatMessageHandlers); - protected CoreConfig _coreConfig = _configServer.GetConfig(); - public UserDialogInfo GetChatBot() { return new UserDialogInfo diff --git a/ModExamples/23CustomAbstractChatBot/23CustomAbstractChatBot.csproj b/ModExamples/23CustomAbstractChatBot/23CustomAbstractChatBot.csproj new file mode 100644 index 00000000..74a98510 --- /dev/null +++ b/ModExamples/23CustomAbstractChatBot/23CustomAbstractChatBot.csproj @@ -0,0 +1,40 @@ + + + + net9.0 + _23CustomAbstractChatBot + enable + enable + Library + + + + + + ..\TempReferences\Core.dll + false + false + false + + + ..\TempReferences\SptCommon.dll + false + false + false + + + ..\TempReferences\SptDependencyInjection.dll + false + false + false + + + + + true + PreserveNewest + PreserveNewest + + + + diff --git a/ModExamples/23CustomAbstractChatBot/Commands/AnotherCoolCommand.cs b/ModExamples/23CustomAbstractChatBot/Commands/AnotherCoolCommand.cs new file mode 100644 index 00000000..13e9935d --- /dev/null +++ b/ModExamples/23CustomAbstractChatBot/Commands/AnotherCoolCommand.cs @@ -0,0 +1,49 @@ +using Core.Helpers.Dialog.Commando; +using Core.Models.Eft.Dialog; +using Core.Models.Eft.Profile; +using Core.Services; + +namespace _23CustomAbstractChatBot.Commands; + +public class AnotherCoolCommand : IChatCommand +{ + private readonly MailSendService _mailSendService; + + public AnotherCoolCommand( + MailSendService mailSendService + ) + { + _mailSendService = mailSendService; + } + + public string GetCommandPrefix() + { + return "anotherExample"; + } + + public string? GetCommandHelp(string command) + { + if (command == "test") + { + return "Usage: anotherExample test"; + } + + return null; + } + + public List GetCommands() + { + return ["test"]; + } + + public string? Handle(string command, UserDialogInfo commandHandler, string sessionId, SendMessageRequest request) + { + if (command == "test") + { + _mailSendService.SendUserMessageToPlayer(sessionId, commandHandler, $"This is another test message shown as a different example!"); + return request.DialogId; + } + + return null; + } +} diff --git a/ModExamples/23CustomAbstractChatBot/Commands/MyCoolCommand.cs b/ModExamples/23CustomAbstractChatBot/Commands/MyCoolCommand.cs new file mode 100644 index 00000000..a87522b7 --- /dev/null +++ b/ModExamples/23CustomAbstractChatBot/Commands/MyCoolCommand.cs @@ -0,0 +1,49 @@ +using Core.Helpers.Dialog.Commando; +using Core.Models.Eft.Dialog; +using Core.Models.Eft.Profile; +using Core.Services; + +namespace _23CustomAbstractChatBot.Commands; + +public class MyCoolCommand : IChatCommand +{ + private readonly MailSendService _mailSendService; + + public MyCoolCommand( + MailSendService mailSendService + ) + { + _mailSendService = mailSendService; + } + + public string GetCommandPrefix() + { + return "example"; + } + + public string? GetCommandHelp(string command) + { + if (command == "test") + { + return "Usage: example test"; + } + + return null; + } + + public List GetCommands() + { + return ["test"]; + } + + public string? Handle(string command, UserDialogInfo commandHandler, string sessionId, SendMessageRequest request) + { + if (command == "test") + { + _mailSendService.SendUserMessageToPlayer(sessionId, commandHandler, $"This is a test message shown as an example!"); + return request.DialogId; + } + + return null; + } +} diff --git a/ModExamples/23CustomAbstractChatBot/CustomAbstractChatBot.cs b/ModExamples/23CustomAbstractChatBot/CustomAbstractChatBot.cs new file mode 100644 index 00000000..db15b5b7 --- /dev/null +++ b/ModExamples/23CustomAbstractChatBot/CustomAbstractChatBot.cs @@ -0,0 +1,43 @@ +using Core.Helpers.Dialog.Commando; +using Core.Helpers.Dialogue; +using Core.Helpers.Dialogue.SPTFriend.Commands; +using Core.Models.Eft.Profile; +using Core.Models.Enums; +using Core.Models.Utils; +using Core.Services; + +namespace _23CustomAbstractChatBot; + +public class CustomAbstractChatBot : AbstractDialogChatBot +{ + public CustomAbstractChatBot( + ISptLogger _logger, + MailSendService _mailSendService, + IEnumerable _chatCommands, + IEnumerable _chatMessageHandlers + ) : base(_logger, _mailSendService, _chatCommands) + { + } + + public override UserDialogInfo GetChatBot() + { + return new UserDialogInfo + { + Id = "674db14ed849a3727ef24da0", // REQUIRES a valid monogo_id, use online generator to create one + Aid = 1234566, + Info = new UserDialogDetails + { + Level = 69, + MemberCategory = MemberCategory.Developer, + SelectedMemberCategory = MemberCategory.Developer, + Nickname = "CoolAbstractChatBot", + Side = "Bear" + } + }; + } + + protected override string GetUnrecognizedCommandMessage() + { + return "No clue what you are talking about bud!"; + } +} diff --git a/ModExamples/23CustomAbstractChatBot/package.json b/ModExamples/23CustomAbstractChatBot/package.json new file mode 100644 index 00000000..c1441df3 --- /dev/null +++ b/ModExamples/23CustomAbstractChatBot/package.json @@ -0,0 +1,13 @@ +{ + "Name": "23CustomAbstractChatBot", + "Version": "1.0.0", + "SptVersion": "~4.0", + "LoadBefore": [], + "LoadAfter": [], + "IncompatibileMods": [], + "Url": "https://github.com/sp-tarkov/server-csharp/tree/develop/ExampleMods/Mods", + "IsBundleMod": false, + "Author": "SPT", + "Contributors": [], + "Licence": "MIT" +} diff --git a/ModExamples/ModExamples.sln b/ModExamples/ModExamples.sln index f89cb5a2..d5ee619c 100644 --- a/ModExamples/ModExamples.sln +++ b/ModExamples/ModExamples.sln @@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "21CustomCommandoCommand", " EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "22CustomSptCommand", "22CustomSptCommand\22CustomSptCommand.csproj", "{7FB8C9B5-CEBF-4E76-9EC3-670EE57B328B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "23CustomAbstractChatBot", "23CustomAbstractChatBot\23CustomAbstractChatBot.csproj", "{B97A7EE2-04DD-4690-866E-9179F5E01908}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -135,6 +137,10 @@ Global {7FB8C9B5-CEBF-4E76-9EC3-670EE57B328B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7FB8C9B5-CEBF-4E76-9EC3-670EE57B328B}.Release|Any CPU.ActiveCfg = Release|Any CPU {7FB8C9B5-CEBF-4E76-9EC3-670EE57B328B}.Release|Any CPU.Build.0 = Release|Any CPU + {B97A7EE2-04DD-4690-866E-9179F5E01908}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B97A7EE2-04DD-4690-866E-9179F5E01908}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B97A7EE2-04DD-4690-866E-9179F5E01908}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B97A7EE2-04DD-4690-866E-9179F5E01908}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE