Removed dupe command RemoveMail that does nothing
Gived `GetMessagePreview` throwing an error when its messages were empty Cleanup of spt friend commands
This commit is contained in:
@@ -296,11 +296,6 @@ public class DialogueCallbacks(
|
||||
return _httpResponseUtil.EmptyArrayResponse();
|
||||
}
|
||||
|
||||
public string RemoveMail(string url, RemoveMailMessageRequest info, string sessionID)
|
||||
{
|
||||
return _httpResponseUtil.EmptyArrayResponse();
|
||||
}
|
||||
|
||||
public string CreateGroupMail(string url, CreateGroupMailRequest info, string sessionID)
|
||||
{
|
||||
return _httpResponseUtil.EmptyArrayResponse();
|
||||
|
||||
@@ -22,6 +22,7 @@ public abstract class AbstractDialogChatBot(
|
||||
if ((request.Text ?? "").Length == 0)
|
||||
{
|
||||
_logger.Error("Command came in as empty text! Invalid data!");
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
@@ -35,49 +36,7 @@ public abstract class AbstractDialogChatBot(
|
||||
|
||||
if (splitCommand.FirstOrDefault()?.ToLower() == "help")
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
"The available commands will be listed below:",
|
||||
[],
|
||||
null
|
||||
);
|
||||
// due to BSG being dumb with messages we need a mandatory timeout between messages so they get out on the right order
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var chatCommand in _chatCommands)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Commands available for \"{chatCommand.GetCommandPrefix()}\" prefix:",
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var subCommand in chatCommand.GetCommands())
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Subcommand {subCommand}:\\n{chatCommand.GetCommandHelp(subCommand)}",
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
|
||||
return request.DialogId;
|
||||
return SendPlayerHelpMessage(sessionId, request);
|
||||
}
|
||||
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
@@ -91,6 +50,53 @@ public abstract class AbstractDialogChatBot(
|
||||
return null;
|
||||
}
|
||||
|
||||
private string? SendPlayerHelpMessage(string sessionId, SendMessageRequest request)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
"The available commands will be listed below:",
|
||||
[],
|
||||
null
|
||||
);
|
||||
// due to BSG being dumb with messages we need a mandatory timeout between messages so they get out on the right order
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var chatCommand in _chatCommands)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Commands available for \"{chatCommand.GetCommandPrefix()}\" prefix:",
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var subCommand in chatCommand.GetCommands())
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Subcommand {subCommand}:\\n{chatCommand.GetCommandHelp(subCommand)}",
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
public void RegisterChatCommand(IChatCommand chatCommand)
|
||||
{
|
||||
if (_chatCommands.Any(cc => cc.GetCommandPrefix() == chatCommand.GetCommandPrefix()))
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
|
||||
namespace Core.Helpers.Dialog.Commando;
|
||||
|
||||
@@ -62,7 +62,7 @@ public class SptCommandoCommands : IChatCommand
|
||||
public string Handle(string command, UserDialogInfo commandHandler, string sessionId, SendMessageRequest request)
|
||||
{
|
||||
return _sptCommands
|
||||
.Find((c) => c.GetCommand() == command)
|
||||
.First((c) => c.GetCommand() == command)
|
||||
.PerformAction(commandHandler, sessionId, request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Text.RegularExpressions;
|
||||
using Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
@@ -23,7 +24,7 @@ public class GiveSptCommand(
|
||||
LocaleService _localeService,
|
||||
ICloner _cloner
|
||||
|
||||
)
|
||||
) : ISptCommand
|
||||
{
|
||||
protected Dictionary<string, SavedCommand> _savedCommand = new();
|
||||
private static readonly Regex _commandRegex = new("""/^spt give(((([a - z]{ 2,5}) )?"(.+)"|\w+) )?([0 - 9]+)$/""");
|
||||
|
||||
+132
-134
@@ -1,9 +1,13 @@
|
||||
using Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using System.Text.RegularExpressions;
|
||||
using Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using Core.Helpers.Dialogue.Commando.SptCommands.GiveCommand;
|
||||
using Core.Models.Eft.Common.Tables;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Models.Enums;
|
||||
using Core.Models.Spt.Dialog;
|
||||
using Core.Models.Spt.Logging;
|
||||
using Core.Models.Utils;
|
||||
using Core.Servers;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
@@ -11,31 +15,28 @@ using Core.Utils;
|
||||
namespace Core.Helpers.Dialogue.Commando.SptCommands.ProfileCommand;
|
||||
|
||||
[Injectable]
|
||||
public class ProfileSptCommand : ISptCommand
|
||||
public class ProfileSptCommand(
|
||||
ISptLogger<ProfileSptCommand> _logger,
|
||||
ItemHelper _itemHelper,
|
||||
HashUtil _hashUtil,
|
||||
PresetHelper _presetHelper,
|
||||
MailSendService _mailSendService,
|
||||
LocaleService _localeService,
|
||||
DatabaseServer dbServer,
|
||||
ProfileHelper _profileHelper
|
||||
) : ISptCommand
|
||||
{
|
||||
// Constructor
|
||||
// (
|
||||
// SptLogger _logger,
|
||||
// ItemHelper _itemHelper,
|
||||
// HashUtil _hashUtil,
|
||||
// PresetHelper _presetHelper,
|
||||
// MailSendService _mailSendService,
|
||||
// LocaleService _localeService,
|
||||
// DatabaseServer dbServer,
|
||||
// ProfileHelper _profileHelper
|
||||
// )
|
||||
|
||||
|
||||
/**
|
||||
* Regex to account for all these cases:
|
||||
* spt profile level 20
|
||||
* spt profile skill metabolism 10
|
||||
*/
|
||||
|
||||
// TODO: Fix this shit as Valens doesn't know Regex.
|
||||
// Regex commandRegex = new Regex(^spt profile (?<command>level|skill)((?<=.*skill) (?<skill>[\w]+)){0,1} (?<quantity>(?!0+)[0-9]+)$/);
|
||||
// Regex examineRegex = new Regex(/^spt profile (?<command>examine)/);
|
||||
protected Regex _commandRegex = new("""^spt profile (?<command>level|skill)((?<=.*skill) (?<skill>[\w]+)){0,1} (?<quantity>(?!0+)[0-9]+)$/""");
|
||||
protected Regex _examineRegex = new ("""/^spt profile (?<command>examine)/""");
|
||||
//
|
||||
// protected savedCommand = SavedCommand;
|
||||
protected SavedCommand _savedCommand = null;
|
||||
|
||||
public string GetCommand()
|
||||
{
|
||||
@@ -51,130 +52,127 @@ public class ProfileSptCommand : ISptCommand
|
||||
|
||||
public string PerformAction(UserDialogInfo commandHandler, string sessionId, SendMessageRequest request)
|
||||
{
|
||||
// TODO: Fix the leftover errors.
|
||||
// if (ProfileSptCommand.commandRegex.test(request.text) is null && ProfileSptCommand.examineRegex.test(request.text) is null) {
|
||||
// _mailSendService.SendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// "Invalid use of trader command. Use 'help' for more information."
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
//
|
||||
// var result =
|
||||
// ProfileSptCommand.commandRegex.exec(request.text) ?? ProfileSptCommand.examineRegex.exec(request.text);
|
||||
//
|
||||
// var command = result.groups.command;
|
||||
// var skill = result.groups.skill;
|
||||
// var quantity = +result.groups.quantity;
|
||||
//
|
||||
// ProfileChangeEvent profileChangeEvent;
|
||||
// switch (command) {
|
||||
// case "level":
|
||||
// if (quantity < 1 || quantity > _profileHelper.GetMaxLevel()) {
|
||||
// _mailSendService.SendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// "Invalid use of profile command, the level was outside bounds: 1 to 70. Use 'help' for more information."
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
// profileChangeEvent = HandleLevelCommand(quantity);
|
||||
// break;
|
||||
// case "skill": {
|
||||
// var enumSkill = SkillTypes.find(
|
||||
// (t) => t.toLocaleLowerCase() === skill.toLocaleLowerCase(),
|
||||
// );
|
||||
//
|
||||
// if (enumSkill == undefined) {
|
||||
// _mailSendService.SendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// "Invalid use of profile command, the skill was not found. Use 'help' for more information."
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
//
|
||||
// if (quantity < 0 || quantity > 51) {
|
||||
// _mailSendService.SendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// "Invalid use of profile command, the skill level was outside bounds: 1 to 51. Use 'help' for more information."
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
//
|
||||
// profileChangeEvent = HandleSkillCommand(enumSkill, quantity);
|
||||
// break;
|
||||
// }
|
||||
// case "examine": {
|
||||
// profileChangeEvent = HandleExamineCommand();
|
||||
// break;
|
||||
// }
|
||||
// default:
|
||||
// _mailSendService.SendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// $"If you are reading this, this is bad. Please report this to SPT staff with a screenshot. Command ${command}."
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
//
|
||||
// _mailSendService.SendSystemMessageToPlayer(
|
||||
// sessionId,
|
||||
// "A single ruble is being attached, required by BSG logic.",
|
||||
// [
|
||||
// {
|
||||
// _id = _hashUtil.generate(),
|
||||
// _tpl = Money.ROUBLES,
|
||||
// upd = { StackObjectsCount: 1 },
|
||||
// parentId = _hashUtil.Generate(),
|
||||
// slotId = "main",
|
||||
// },
|
||||
// ],
|
||||
// undefined,
|
||||
// [profileChangeEvent]
|
||||
// );
|
||||
// return request.DialogId;
|
||||
throw new NotImplementedException();
|
||||
var isCommand = _commandRegex.IsMatch(request.Text);
|
||||
var isExamine = _examineRegex.IsMatch(request.Text);
|
||||
|
||||
if (!isCommand && !isExamine) {
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
"Invalid use of trader command. Use 'help' for more information."
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
var result = _commandRegex.Match(request.Text);
|
||||
|
||||
var command = result.Groups["command"].Captures[0].Value;
|
||||
var skill = result.Groups["skill"].Captures[0].Value;
|
||||
var quantity = int.Parse(result.Groups["quantity"].Captures[0].Value);
|
||||
|
||||
ProfileChangeEvent profileChangeEvent;
|
||||
switch (command) {
|
||||
case "level":
|
||||
if (quantity < 1 || quantity > _profileHelper.GetMaxLevel()) {
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
"Invalid use of profile command, the level was outside bounds: 1 to 70. Use 'help' for more information."
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
profileChangeEvent = HandleLevelCommand(quantity);
|
||||
break;
|
||||
case "skill": {
|
||||
var enumSkill = Enum.GetValues(typeof(SkillTypes)).Cast<SkillTypes>().FirstOrDefault(
|
||||
(t) => t.ToString() == skill);
|
||||
|
||||
if (enumSkill == null) {
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
"Invalid use of profile command, the skill was not found. Use 'help' for more information."
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
if (quantity < 0 || quantity > 51) {
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
"Invalid use of profile command, the skill level was outside bounds: 1 to 51. Use 'help' for more information."
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
profileChangeEvent = HandleSkillCommand(enumSkill, quantity);
|
||||
break;
|
||||
}
|
||||
case "examine": {
|
||||
profileChangeEvent = HandleExamineCommand();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
$"If you are reading this, this is bad. Please report this to SPT staff with a screenshot. Command ${command}."
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
_mailSendService.SendSystemMessageToPlayer(
|
||||
sessionId,
|
||||
"A single ruble is being attached, required by BSG logic.",
|
||||
[
|
||||
new Item{
|
||||
Id = _hashUtil.Generate(),
|
||||
Template = Money.ROUBLES,
|
||||
Upd = new Upd{ StackObjectsCount = 1 },
|
||||
ParentId = _hashUtil.Generate(),
|
||||
SlotId = "main",
|
||||
},
|
||||
],
|
||||
null,
|
||||
[profileChangeEvent]
|
||||
);
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
protected ProfileChangeEvent HandleSkillCommand(string skill, int level)
|
||||
protected ProfileChangeEvent HandleSkillCommand(SkillTypes skill, int level)
|
||||
{
|
||||
// TODO: Fix the leftover errors.
|
||||
// ProfileChangeEvent profileChangeEvent = {
|
||||
// _id = _hashUtil.Generate(),
|
||||
// Type = ProfileChangeEventType.SkillPoints,
|
||||
// value = level * 100,
|
||||
// entity = skill,
|
||||
// };
|
||||
// return profileChangeEvent;
|
||||
throw new NotImplementedException();
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.SkillPoints,
|
||||
Value = level * 100,
|
||||
Entity = skill.ToString(),
|
||||
};
|
||||
return profileChangeEvent;
|
||||
}
|
||||
|
||||
protected ProfileChangeEvent HandleLevelCommand(int level)
|
||||
{
|
||||
// TODO: Fix the leftover errors.
|
||||
// var exp = _profileHelper.GetExperience(level);
|
||||
// ProfileChangeEvent profileChangeEvent = {
|
||||
// _id = _hashUtil.Generate(),
|
||||
// Type = ProfileChangeEventType.ProfileLevel,
|
||||
// value = exp,
|
||||
// entity = undefined,
|
||||
// };
|
||||
// return profileChangeEvent;
|
||||
throw new NotImplementedException();
|
||||
var exp = _profileHelper.GetExperience(level);
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.ProfileLevel,
|
||||
Value = exp,
|
||||
Entity = null,
|
||||
};
|
||||
return profileChangeEvent;
|
||||
}
|
||||
|
||||
protected ProfileChangeEvent HandleExamineCommand() {
|
||||
// TODO: Fix the leftover errors.
|
||||
// ProfileChangeEvent profileChangeEvent = {
|
||||
// id = _hashUtil.Generate(),
|
||||
// Type = ProfileChangeEventType.ExamineAllItems,
|
||||
// value = undefined,
|
||||
// entity = undefined,
|
||||
// };
|
||||
// return profileChangeEvent;
|
||||
throw new NotImplementedException();
|
||||
var profileChangeEvent = new ProfileChangeEvent
|
||||
{
|
||||
Id = _hashUtil.Generate(),
|
||||
Type = ProfileChangeEventType.ExamineAllItems,
|
||||
Value = null,
|
||||
Entity = null,
|
||||
};
|
||||
|
||||
return profileChangeEvent;
|
||||
}
|
||||
}
|
||||
|
||||
+21
-15
@@ -1,12 +1,19 @@
|
||||
using SptCommon.Annotations;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Services;
|
||||
using System.Text.RegularExpressions;
|
||||
using Core.Models.Utils;
|
||||
|
||||
namespace Core.Helpers.Dialog.Commando.SptCommands.TraderCommand;
|
||||
|
||||
[Injectable]
|
||||
public class TraderSptCommand : ISptCommand
|
||||
public class TraderSptCommand(
|
||||
ISptLogger<TraderSptCommand> _logger,
|
||||
MailSendService _mailSendService) : ISptCommand
|
||||
{
|
||||
protected Regex _commandRegex = new("""/^spt trader(?<trader>[\w]+) (?<command>rep|spend) (?<quantity>(?!0+)[0 - 9]+)$/""");
|
||||
|
||||
public string GetCommand()
|
||||
{
|
||||
return "trader";
|
||||
@@ -19,19 +26,18 @@ public class TraderSptCommand : ISptCommand
|
||||
|
||||
public string PerformAction(UserDialogInfo commandHandler, string sessionId, SendMessageRequest request)
|
||||
{
|
||||
// TODO: Finish implementation/fix errors.
|
||||
// if (TraderSptCommand.commandRegex.test(request.text) is null)
|
||||
// {
|
||||
// this.mailSendService.sendUserMessageToPlayer(
|
||||
// sessionId,
|
||||
// commandHandler,
|
||||
// "Invalid use of trader command. Use 'help' for more information.",
|
||||
// );
|
||||
// return request.DialogId;
|
||||
// }
|
||||
//
|
||||
// return request.DialogId;
|
||||
if (!_commandRegex.IsMatch(request.Text))
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
"Invalid use of trader command. Use 'help' for more information.");
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
// TODO: implement remaining, copy from give command
|
||||
_logger.Error("NOT IMPLEMENTED: TraderSptCommand");
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
using Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Services;
|
||||
+1
-1
@@ -3,7 +3,7 @@ using Core.Models.Eft.Profile;
|
||||
using Core.Services;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
|
||||
[Injectable]
|
||||
public class FishMessageHandler(
|
||||
+1
-1
@@ -5,7 +5,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class ForceChristmasMessageHandler(
|
||||
+3
-3
@@ -5,7 +5,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class ForceHalloweenMessageHandler(
|
||||
@@ -34,8 +34,8 @@ namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
sptFriendUser,
|
||||
_randomUtil.GetArrayValue([
|
||||
_localisationService.GetText("chatbot-forced_event_enabled", SeasonalEventType.Halloween)
|
||||
]),
|
||||
[],
|
||||
]),
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class ForceSnowMessageHandler(
|
||||
@@ -36,7 +36,7 @@ namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
sessionId,
|
||||
sptFriendUser,
|
||||
_randomUtil.GetArrayValue([_localisationService.GetText("chatbot-snow_enabled")]),
|
||||
[],
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
+2
-2
@@ -7,7 +7,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class ForceSummerMessageHandler(
|
||||
@@ -36,7 +36,7 @@ namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
sessionId,
|
||||
sptFriendUser,
|
||||
_randomUtil.GetArrayValue([_localisationService.GetText("chatbot-summer_enabled")]),
|
||||
[],
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
+1
-1
@@ -6,7 +6,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
|
||||
[Injectable]
|
||||
public class GiveMeSpaceMessageHandler(
|
||||
+47
-2
@@ -1,18 +1,63 @@
|
||||
using Core.Helpers.Dialog.Commando.SptCommands;
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class HelloMessageHandler(
|
||||
MailSendService _mailSendService,
|
||||
RandomUtil _randomUtil) : IChatMessageHandler
|
||||
RandomUtil _randomUtil) : ISptCommand
|
||||
{
|
||||
protected List<string> _listOfMessages = ["hello", "hi", "sup", "yo", "hey", "bonjour"];
|
||||
|
||||
|
||||
public string GetCommand()
|
||||
{
|
||||
return "hello";
|
||||
}
|
||||
|
||||
public string GetAssociatedBotId()
|
||||
{
|
||||
return "6723fd51c5924c57ce0ca01f";
|
||||
}
|
||||
|
||||
public string GetCommandHelp()
|
||||
{
|
||||
return "'hello' replies to the player with a random greeting";
|
||||
}
|
||||
|
||||
public string PerformAction(UserDialogInfo commandHandler, string sessionId, SendMessageRequest request)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
commandHandler,
|
||||
_randomUtil.GetArrayValue([
|
||||
"Howdy",
|
||||
"Hi",
|
||||
"Greetings",
|
||||
"Hello",
|
||||
"Bonjor",
|
||||
"Yo",
|
||||
"Sup",
|
||||
"Heyyyyy",
|
||||
"Hey there",
|
||||
"OH its you"
|
||||
]),
|
||||
[], null
|
||||
);
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public int GetPriority()
|
||||
{
|
||||
return 100;
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
using Core.Models.Eft.Common;
|
||||
using Core.Models.Eft.Profile;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
|
||||
public interface IChatMessageHandler
|
||||
{
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
|
||||
[Injectable]
|
||||
public class LoveYouChatMessageHandler(
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class NikitaMessageHandler(
|
||||
+1
-1
@@ -7,7 +7,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands
|
||||
{
|
||||
[Injectable]
|
||||
public class SendGiftMessageHandler(
|
||||
+1
-1
@@ -4,7 +4,7 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using SptCommon.Annotations;
|
||||
|
||||
namespace Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
namespace Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
|
||||
[Injectable]
|
||||
public class SptMessageHandler(
|
||||
@@ -1,5 +1,6 @@
|
||||
using SptCommon.Annotations;
|
||||
using Core.Helpers.Dialog.Commando;
|
||||
using Core.Helpers.Dialogue.SPTFriend.Commands;
|
||||
using Core.Models.Eft.Dialog;
|
||||
using Core.Models.Eft.Profile;
|
||||
using Core.Models.Enums;
|
||||
@@ -7,8 +8,7 @@ using Core.Models.Spt.Config;
|
||||
using Core.Models.Utils;
|
||||
using Core.Servers;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using Core.Helpers.Dialogue.SptMessageHandlers;
|
||||
using Core.Utils.Callbacks;
|
||||
|
||||
namespace Core.Helpers.Dialogue;
|
||||
|
||||
@@ -57,8 +57,80 @@ public class SptDialogueChatBot(
|
||||
var sender = _profileHelper.GetPmcProfile(sessionId);
|
||||
var sptFriendUser = GetChatBot();
|
||||
|
||||
_chatMessageHandlers.FirstOrDefault((v) => v.CanHandle(request.Text))
|
||||
.Process(sessionId, sptFriendUser, sender);
|
||||
if (request.Text?.ToLower() == "help")
|
||||
{
|
||||
return SendPlayerHelpMessage(sessionId, request);
|
||||
}
|
||||
|
||||
|
||||
var handler = _chatMessageHandlers.FirstOrDefault((v) => v.CanHandle(request.Text));
|
||||
if (handler is not null)
|
||||
{
|
||||
handler.Process(sessionId, sptFriendUser, sender);
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
GetUnrecognizedCommandMessage(),
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
private string GetUnrecognizedCommandMessage()
|
||||
{
|
||||
return "Unknown command.";
|
||||
}
|
||||
|
||||
private string? SendPlayerHelpMessage(string sessionId, SendMessageRequest request)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
"The available commands are:\\n GIVEMESPACE \\n HOHOHO \\n VERYSPOOKY \\n ITSONLYSNOWALAN \\n GIVEMESUNSHINE",
|
||||
[],
|
||||
null
|
||||
);
|
||||
// due to BSG being dumb with messages we need a mandatory timeout between messages so they get out on the right order
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var chatCommand in _chatCommands)
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Commands available for \"{chatCommand.GetCommandPrefix()}\" prefix:",
|
||||
[],
|
||||
null
|
||||
);
|
||||
|
||||
TimeoutCallback.RunInTimespan(
|
||||
() =>
|
||||
{
|
||||
foreach (var subCommand in chatCommand.GetCommands())
|
||||
{
|
||||
_mailSendService.SendUserMessageToPlayer(
|
||||
sessionId,
|
||||
GetChatBot(),
|
||||
$"Subcommand {subCommand}:\\n{chatCommand.GetCommandHelp(subCommand)}",
|
||||
[],
|
||||
null
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
}
|
||||
},
|
||||
TimeSpan.FromSeconds(1)
|
||||
);
|
||||
|
||||
return request.DialogId;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public class DialogueHelper(
|
||||
public MessagePreview GetMessagePreview(Models.Eft.Profile.Dialogue? dialogue)
|
||||
{
|
||||
// The last message of the dialogue should be shown on the preview.
|
||||
var message = dialogue.Messages[dialogue.Messages.Count - 1];
|
||||
var message = dialogue.Messages.Last();
|
||||
MessagePreview result = new()
|
||||
{
|
||||
DateTime = message?.DateTime,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using SptCommon.Annotations;
|
||||
using SptCommon.Annotations;
|
||||
using Core.Callbacks;
|
||||
using Core.DI;
|
||||
using Core.Models.Eft.Common;
|
||||
@@ -91,15 +91,6 @@ public class DialogStaticRouter : StaticRouter
|
||||
output
|
||||
) => _dialogueCallbacks.SetRead(url, info as SetDialogReadRequestData, sessionID),
|
||||
typeof(SetDialogReadRequestData)),
|
||||
new RouteAction(
|
||||
"/client/mail/dialog/remove",
|
||||
(
|
||||
url,
|
||||
info,
|
||||
sessionID,
|
||||
output
|
||||
) => _dialogueCallbacks.RemoveMail(url, info as RemoveMailMessageRequest, sessionID),
|
||||
typeof(RemoveMailMessageRequest)),
|
||||
new RouteAction(
|
||||
"/client/mail/dialog/getAllAttachments",
|
||||
(
|
||||
|
||||
@@ -321,7 +321,7 @@ public class MailSendService(
|
||||
public void SendPlayerMessageToNpc(string sessionId, string targetNpcId, string message)
|
||||
{
|
||||
var playerProfile = _saveServer.GetProfile(sessionId);
|
||||
if (playerProfile.DialogueRecords != null ||
|
||||
if (playerProfile.DialogueRecords is null ||
|
||||
!playerProfile.DialogueRecords.TryGetValue(targetNpcId, out var dialogWithNpc))
|
||||
{
|
||||
_logger.Error(_localisationService.GetText("mailsend-missing_npc_dialog", targetNpcId));
|
||||
|
||||
@@ -121,9 +121,10 @@ public class RagfairOfferService(
|
||||
public void RemoveOfferById(string offerId)
|
||||
{
|
||||
var offer = ragfairOfferHolder.GetOfferById(offerId);
|
||||
if (offer == null)
|
||||
if (offer is null)
|
||||
{
|
||||
logger.Warning(localisationService.GetText("ragfair-unable_to_remove_offer_doesnt_exist", offerId));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user