Support chat message queuing from chat commands.

This commit is contained in:
Dominion
2023-04-03 12:29:16 -04:00
parent 2ef30b2290
commit 28571bd056
5 changed files with 34 additions and 18 deletions
+2 -2
View File
@@ -8,8 +8,8 @@
<TgsApiVersion>9.9.0</TgsApiVersion>
<TgsApiLibraryVersion>10.3.0</TgsApiLibraryVersion>
<TgsClientVersion>11.3.0</TgsClientVersion>
<TgsDmapiVersion>6.2.1</TgsDmapiVersion>
<TgsInteropVersion>5.4.0</TgsInteropVersion>
<TgsDmapiVersion>6.3.0</TgsDmapiVersion>
<TgsInteropVersion>5.5.0</TgsInteropVersion>
<TgsHostWatchdogVersion>1.2.1</TgsHostWatchdogVersion>
<TgsContainerScriptVersion>1.2.1</TgsContainerScriptVersion>
<TgsMigratorVersion>1.0.1</TgsMigratorVersion>
+1 -1
View File
@@ -1,6 +1,6 @@
// tgstation-server DMAPI
#define TGS_DMAPI_VERSION "6.2.1"
#define TGS_DMAPI_VERSION "6.3.0"
// All functions and datums outside this document are subject to change with any version and should not be relied on.
+1 -1
View File
@@ -1 +1 @@
"5.4.0"
"5.5.0"
+3
View File
@@ -129,9 +129,12 @@
switch(command)
if(DMAPI5_TOPIC_COMMAND_CHAT_COMMAND)
intercepted_message_queue = list()
var/result = HandleCustomCommand(topic_parameters[DMAPI5_TOPIC_PARAMETER_CHAT_COMMAND])
if(!result)
result = TopicResponse("Error running chat command!")
result[DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES] = intercepted_message_queue
intercepted_message_queue = null
return result
if(DMAPI5_TOPIC_COMMAND_EVENT_NOTIFICATION)
intercepted_message_queue = list()
@@ -307,6 +307,8 @@ namespace Tgstation.Server.Host.Components.Watchdog
commandResponse.Text = "TGS: Command processed but no DMAPI response returned!";
}
HandleChatResponses(commandResult);
return commandResponse;
}
}
@@ -465,20 +467,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
cancellationToken)
;
if (result?.InteropResponse?.ChatResponses != null)
foreach (var response in result.InteropResponse.ChatResponses)
Chat.QueueMessage(
response,
response.ChannelIds
.Select(channelIdString =>
{
if (UInt64.TryParse(channelIdString, out var channelId))
return (ulong?)channelId;
return null;
})
.Where(nullableChannelId => nullableChannelId.HasValue)
.Select(nullableChannelId => nullableChannelId.Value));
HandleChatResponses(result);
}
/// <summary>
@@ -1100,5 +1089,29 @@ namespace Tgstation.Server.Host.Components.Watchdog
return MonitorAction.Continue;
}
/// <summary>
/// Handle any <see cref="TopicResponse.ChatResponses"/> in a given topic <paramref name="result"/>.
/// </summary>
/// <param name="result">The <see cref="CombinedTopicResponse"/>.</param>
void HandleChatResponses(CombinedTopicResponse result)
{
if (result?.InteropResponse?.ChatResponses != null)
foreach (var response in result.InteropResponse.ChatResponses)
Chat.QueueMessage(
response,
response.ChannelIds
.Select(channelIdString =>
{
if (UInt64.TryParse(channelIdString, out var channelId))
return (ulong?)channelId;
else
Logger.LogWarning("Could not parse chat response channel ID: {channelID}", channelIdString);
return null;
})
.Where(nullableChannelId => nullableChannelId.HasValue)
.Select(nullableChannelId => nullableChannelId.Value));
}
}
}