mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-23 21:16:52 +01:00
Finish writing DMAPI5 definitions I think
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
#define DMAPI5_BRIDGE_COMMAND_KILL 4
|
||||
#define DMAPI5_BRIDGE_COMMAND_CHAT_SEND 5
|
||||
|
||||
#define DMAPI5_PARAMETER_ACCESS_IDENTIFIER "accessIdentifier"
|
||||
|
||||
#define DMAPI5_BRIDGE_PARAMETER_COMMAND "commandType"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_NEW_PORT "newPort"
|
||||
#define DMAPI5_BRIDGE_PARAMETER_VERSION "version"
|
||||
@@ -37,4 +39,40 @@
|
||||
|
||||
#define DMAPI5_CHAT_COMMAND_NAME "name"
|
||||
#define DMAPI5_CHAT_COMMAND_PARAMS "params"
|
||||
#defin
|
||||
#define DMAPI5_CHAT_COMMAND_USER "user"
|
||||
|
||||
#define DMAPI5_EVENT_NOTIFICATION_TYPE "type"
|
||||
#define DMAPI5_EVENT_NOTIFICATION_PARAMETERS "parameters"
|
||||
|
||||
#define DMAPI5_TOPIC_COMMAND_CHAT_COMMAND 0
|
||||
#define DMAPI5_TOPIC_COMMAND_EVENT_NOTIFICATION 1
|
||||
#define DMAPI5_TOPIC_COMMAND_CHANGE_PORT 2
|
||||
#define DMAPI5_TOPIC_COMMAND_CHANGE_REBOOT_STATE 3
|
||||
#define DMAPI5_TOPIC_COMMAND_INSTANCE_RENAMED 4
|
||||
|
||||
#define DMAPI5_TOPIC_PARAMETER_COMMAND_TYPE "commandType"
|
||||
#define DMAPI5_TOPIC_PARAMETER_CHAT_COMMAND "chatCommand"
|
||||
#define DMAPI5_TOPIC_PARAMETER_EVENT_NOTIFICATION "eventNotification"
|
||||
#define DMAPI5_TOPIC_PARAMETER_NEW_PORT "newPort"
|
||||
#define DMAPI5_TOPIC_PARAMETER_NEW_REBOOT_STATE "newRebootState"
|
||||
#define DMAPI5_TOPIC_PARAMETER_NEW_INSTANCE_NAME "newInstanceName"
|
||||
|
||||
#define DMAPI5_TOPIC_RESPONSE_ERROR_MESSAGE "errorMessage"
|
||||
#define DMAPI5_TOPIC_RESPONSE_COMMAND_RESPONSE_MESSAGE "commandResponseMessage"
|
||||
#define DMAPI5_TOPIC_RESPONSE_CHAT_RESPONSES "chatResponses"
|
||||
|
||||
#define DMAPI5_REVISION_INFORMATION_COMMIT_SHA "commitSha"
|
||||
#define DMAPI5_REVISION_INFORMATION_ORIGIN_COMMIT_SHA "originCommitSha"
|
||||
|
||||
#define DMAPI5_CHAT_USER_ID "id"
|
||||
#define DMAPI5_CHAT_USER_FRIENDLY_NAME "friendlyName"
|
||||
#define DMAPI5_CHAT_USER_MENTION "mention"
|
||||
#define DMAPI5_CHAT_USER_CHANNEL "channel"
|
||||
|
||||
#define DMAPI5_CHAT_CHANNEL_ID "id"
|
||||
#define DMAPI5_CHAT_CHANNEL_FRIENDLY_NAME "friendlyName"
|
||||
#define DMAPI5_CHAT_CHANNEL_CONNECTION_NAME "connectionName"
|
||||
#define DMAPI5_CHAT_CHANNEL_IS_ADMIN_CHANNEL "isAdminChannel"
|
||||
#define DMAPI5_CHAT_CHANNEL_IS_PRIVATE_CHANNEL "isPrivateChannel"
|
||||
#define DMAPI5_CHAT_CHANNEL_IS_WATCHDOG_CHANNEL "isWatchdogChannel"
|
||||
#define DMAPI5_CHAT_CHANNEL_TAG "tag"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Tgstation.Server.Host.Components.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a mapping of a <see cref="Channel.RealId"/>
|
||||
/// Represents a mapping of a <see cref="ChatChannel.RealId"/>
|
||||
/// </summary>
|
||||
sealed class ChannelMapping
|
||||
{
|
||||
@@ -11,7 +11,7 @@
|
||||
public long ProviderId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The original <see cref="Components.Chat.Channel.RealId"/>
|
||||
/// The original <see cref="Components.Chat.ChatChannel.RealId"/>
|
||||
/// </summary>
|
||||
public ulong ProviderChannelId { get; set; }
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
public bool IsUpdatesChannel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Components.Chat.Channel"/> with the mapped Id
|
||||
/// The <see cref="Components.Chat.ChatChannel"/> with the mapped Id
|
||||
/// </summary>
|
||||
public Channel Channel { get; set; }
|
||||
public ChatChannel Channel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
readonly Dictionary<long, IProvider> providers;
|
||||
|
||||
/// <summary>
|
||||
/// Map of <see cref="Channel.RealId"/>s to <see cref="ChannelMapping"/>s
|
||||
/// Map of <see cref="ChatChannel.RealId"/>s to <see cref="ChannelMapping"/>s
|
||||
/// </summary>
|
||||
readonly Dictionary<ulong, ChannelMapping> mappedChannels;
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
TaskCompletionSource<object> connectionsUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Used for remapping <see cref="Channel.RealId"/>s
|
||||
/// Used for remapping <see cref="ChatChannel.RealId"/>s
|
||||
/// </summary>
|
||||
ulong channelIdCounter;
|
||||
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Represents a <see cref="Providers.IProvider"/> channel
|
||||
/// </summary>
|
||||
public sealed class Channel
|
||||
public sealed class ChatChannel
|
||||
{
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="RealId"/>. Represented as a <see cref="string"/> to avoid BYOND percision loss
|
||||
@@ -26,12 +26,12 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The user friendly name of the <see cref="Channel"/>
|
||||
/// The user friendly name of the <see cref="ChatChannel"/>
|
||||
/// </summary>
|
||||
public string FriendlyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the connection the <see cref="Channel"/> belongs to
|
||||
/// The name of the connection the <see cref="ChatChannel"/> belongs to
|
||||
/// </summary>
|
||||
public string ConnectionName { get; set; }
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Represents a tgs_chat_user datum
|
||||
/// </summary>
|
||||
public sealed class User
|
||||
public sealed class ChatUser
|
||||
{
|
||||
/// <summary>
|
||||
/// Backing field for <see cref="RealId"/>. Represented as a <see cref="string"/> to avoid BYOND percision loss
|
||||
@@ -35,8 +35,8 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
public string Mention { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Components.Chat.Channel"/> the user spoke from
|
||||
/// The <see cref="Components.Chat.ChatChannel"/> the user spoke from
|
||||
/// </summary>
|
||||
public Channel Channel { get; set; }
|
||||
public ChatChannel Channel { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken)
|
||||
public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE"))
|
||||
return Task.FromResult(byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor));
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken)
|
||||
public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
if (handler == null)
|
||||
throw new InvalidOperationException("SetHandler() has not been called!");
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
string HelpText { get; }
|
||||
|
||||
/// <summary>
|
||||
/// If the command should only be available to <see cref="User"/>s who's <see cref="User.Channel"/> has <see cref="Channel.IsAdminChannel"/> set
|
||||
/// If the command should only be available to <see cref="ChatUser"/>s who's <see cref="ChatUser.Channel"/> has <see cref="ChatChannel.IsAdminChannel"/> set
|
||||
/// </summary>
|
||||
bool AdminOnly { get; }
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
/// Invoke the <see cref="ICommand"/>
|
||||
/// </summary>
|
||||
/// <param name="arguments">The text after <see cref="Name"/> with leading whitespace trimmed</param>
|
||||
/// <param name="user">The <see cref="User"/> who invoked the command</param>
|
||||
/// <param name="user">The <see cref="ChatUser"/> who invoked the command</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="string"/> to send to the invoker</returns>
|
||||
Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken);
|
||||
Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,6 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
public bool AdminOnly => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken) => Task.FromResult(Kek);
|
||||
public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(Kek);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
/// <inheritdoc />
|
||||
// TODO: Decomplexify
|
||||
#pragma warning disable CA1506
|
||||
public async Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken)
|
||||
public async Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
IEnumerable<Models.TestMerge> results = null;
|
||||
if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO"))
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken)
|
||||
public async Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken)
|
||||
{
|
||||
string result;
|
||||
if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO"))
|
||||
|
||||
@@ -34,6 +34,6 @@ namespace Tgstation.Server.Host.Components.Chat.Commands
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public Task<string> Invoke(string arguments, User user, CancellationToken cancellationToken) => Task.FromResult(application.VersionString);
|
||||
public Task<string> Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(application.VersionString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// </summary>
|
||||
/// <param name="commandName">The command name</param>
|
||||
/// <param name="arguments">Everything typed after <paramref name="commandName"/> minus leading spaces</param>
|
||||
/// <param name="sender">The sending <see cref="User"/></param>
|
||||
/// <param name="sender">The sending <see cref="ChatUser"/></param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the response text to send back</returns>
|
||||
Task<string> HandleChatCommand(string commandName, string arguments, User sender, CancellationToken cancellationToken);
|
||||
Task<string> HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -26,9 +26,9 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
/// <summary>
|
||||
/// Writes information about connected <paramref name="channels"/> to the <see cref="IJsonTrackingContext"/>
|
||||
/// </summary>
|
||||
/// <param name="channels">The <see cref="Channel"/>s to write out</param>
|
||||
/// <param name="channels">The <see cref="ChatChannel"/>s to write out</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
Task SetChannels(IEnumerable<Channel> channels, CancellationToken cancellationToken);
|
||||
Task SetChannels(IEnumerable<ChatChannel> channels, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace Tgstation.Server.Host.Components.Chat
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task SetChannels(IEnumerable<Channel> channels, CancellationToken cancellationToken)
|
||||
public async Task SetChannels(IEnumerable<ChatChannel> channels, CancellationToken cancellationToken)
|
||||
{
|
||||
using (await SemaphoreSlimContext.Lock(channelsSemaphore, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Components.Chat.User"/> who sent the <see cref="Message"/>
|
||||
/// The <see cref="Components.Chat.ChatUser"/> who sent the <see cref="Message"/>
|
||||
/// </summary>
|
||||
public User User { get; set; }
|
||||
public ChatUser User { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -101,10 +101,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
var result = new Message
|
||||
{
|
||||
Content = e.Content,
|
||||
User = new User
|
||||
User = new ChatUser
|
||||
{
|
||||
RealId = e.Author.Id,
|
||||
Channel = new Channel
|
||||
Channel = new ChatChannel
|
||||
{
|
||||
RealId = e.Channel.Id,
|
||||
IsPrivateChannel = pm,
|
||||
@@ -193,7 +193,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task<IReadOnlyCollection<Channel>> MapChannels(IEnumerable<ChatChannel> channels, CancellationToken cancellationToken)
|
||||
public override Task<IReadOnlyCollection<ChatChannel>> MapChannels(IEnumerable<Api.Models.ChatChannel> channels, CancellationToken cancellationToken)
|
||||
{
|
||||
if (channels == null)
|
||||
throw new ArgumentNullException(nameof(channels));
|
||||
@@ -201,10 +201,10 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
if (!Connected)
|
||||
{
|
||||
Logger.LogWarning("Cannot map channels, provider disconnected!");
|
||||
return Task.FromResult<IReadOnlyCollection<Channel>>(Array.Empty<Channel>());
|
||||
return Task.FromResult<IReadOnlyCollection<ChatChannel>>(Array.Empty<ChatChannel>());
|
||||
}
|
||||
|
||||
Channel GetModelChannelFromDBChannel(ChatChannel channelFromDB)
|
||||
ChatChannel GetModelChannelFromDBChannel(Api.Models.ChatChannel channelFromDB)
|
||||
{
|
||||
if (!channelFromDB.DiscordChannelId.HasValue)
|
||||
throw new InvalidOperationException("ChatChannel missing DiscordChannelId!");
|
||||
@@ -213,7 +213,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
var discordChannel = client.GetChannel(channelId);
|
||||
if (discordChannel is ITextChannel textChannel)
|
||||
{
|
||||
var channelModel = new Channel
|
||||
var channelModel = new ChatChannel
|
||||
{
|
||||
RealId = discordChannel.Id,
|
||||
IsAdminChannel = channelFromDB.IsAdminChannel == true,
|
||||
@@ -238,7 +238,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
mappedChannels.AddRange(enumerator.Select(x => x.RealId));
|
||||
}
|
||||
|
||||
return Task.FromResult<IReadOnlyCollection<Channel>>(enumerator);
|
||||
return Task.FromResult<IReadOnlyCollection<ChatChannel>>(enumerator);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in the next available <see cref="Message"/> or <see langword="null"/> if the <see cref="IProvider"/> needed to reconnect.</returns>
|
||||
/// <remarks>Note that private messages will come in the form of <see cref="Channel"/>s not returned in <see cref="MapChannels(IEnumerable{Api.Models.ChatChannel}, CancellationToken)"/>. Do not <see cref="IDisposable.Dispose"/> the <see cref="IProvider"/> on continuations run from the returned <see cref="Task"/>.</remarks>
|
||||
/// <remarks>Note that private messages will come in the form of <see cref="ChatChannel"/>s not returned in <see cref="MapChannels(IEnumerable{Api.Models.ChatChannel}, CancellationToken)"/>. Do not <see cref="IDisposable.Dispose"/> the <see cref="IProvider"/> on continuations run from the returned <see cref="Task"/>.</remarks>
|
||||
Task<Message> NextMessage(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
@@ -43,17 +43,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
Task Disconnect(CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Get the <see cref="Channel"/>s for given <paramref name="channels"/>
|
||||
/// Get the <see cref="ChatChannel"/>s for given <paramref name="channels"/>
|
||||
/// </summary>
|
||||
/// <param name="channels">The <see cref="Api.Models.ChatChannel"/>s to map</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyCollection{T}"/> of the <see cref="Channel"/>s representing <paramref name="channels"/></returns>
|
||||
Task<IReadOnlyCollection<Channel>> MapChannels(IEnumerable<Api.Models.ChatChannel> channels, CancellationToken cancellationToken);
|
||||
/// <returns>A <see cref="Task{TResult}"/> resulting in a <see cref="IReadOnlyCollection{T}"/> of the <see cref="ChatChannel"/>s representing <paramref name="channels"/></returns>
|
||||
Task<IReadOnlyCollection<ChatChannel>> MapChannels(IEnumerable<Api.Models.ChatChannel> channels, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Send a message to the <see cref="IProvider"/>
|
||||
/// </summary>
|
||||
/// <param name="channelId">The <see cref="Channel.RealId"/> to send to</param>
|
||||
/// <param name="channelId">The <see cref="ChatChannel.RealId"/> to send to</param>
|
||||
/// <param name="message">The message contents</param>
|
||||
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation</param>
|
||||
/// <returns>A <see cref="Task"/> representing the running operation</returns>
|
||||
|
||||
+1
-2
@@ -1,7 +1,6 @@
|
||||
using Tgstation.Server.Api.Models.Internal;
|
||||
using Tgstation.Server.Host.Components.Chat.Providers;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Chat
|
||||
namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
{
|
||||
/// <summary>
|
||||
/// Factory for <see cref="IProvider"/>s
|
||||
@@ -61,12 +61,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
readonly IrcPasswordType? passwordType;
|
||||
|
||||
/// <summary>
|
||||
/// Map of <see cref="Channel.RealId"/>s to channel names
|
||||
/// Map of <see cref="ChatChannel.RealId"/>s to channel names
|
||||
/// </summary>
|
||||
readonly Dictionary<ulong, string> channelIdMap;
|
||||
|
||||
/// <summary>
|
||||
/// Map of <see cref="Channel.RealId"/>s to query users
|
||||
/// Map of <see cref="ChatChannel.RealId"/>s to query users
|
||||
/// </summary>
|
||||
readonly Dictionary<ulong, string> queryChannelIdMap;
|
||||
|
||||
@@ -210,9 +210,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
var message = new Message
|
||||
{
|
||||
Content = e.Data.Message,
|
||||
User = new User
|
||||
User = new ChatUser
|
||||
{
|
||||
Channel = new Channel
|
||||
Channel = new ChatChannel
|
||||
{
|
||||
ConnectionName = address,
|
||||
FriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName,
|
||||
@@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override Task<IReadOnlyCollection<Channel>> MapChannels(IEnumerable<ChatChannel> channels, CancellationToken cancellationToken) => Task.Factory.StartNew(() =>
|
||||
public override Task<IReadOnlyCollection<ChatChannel>> MapChannels(IEnumerable<Api.Models.ChatChannel> channels, CancellationToken cancellationToken) => Task.Factory.StartNew(() =>
|
||||
{
|
||||
if (channels.Any(x => x.IrcChannel == null))
|
||||
throw new InvalidOperationException("ChatChannel missing IrcChannel!");
|
||||
@@ -394,7 +394,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
foreach (var I in hs)
|
||||
client.RfcJoin(I);
|
||||
|
||||
return (IReadOnlyCollection<Channel>)channels.Select(x =>
|
||||
return (IReadOnlyCollection<ChatChannel>)channels.Select(x =>
|
||||
{
|
||||
ulong? id = null;
|
||||
if (!channelIdMap.Any(y =>
|
||||
@@ -409,7 +409,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
channelIdMap.Add(id.Value, x.IrcChannel);
|
||||
}
|
||||
|
||||
return new Channel
|
||||
return new ChatChannel
|
||||
{
|
||||
RealId = id.Value,
|
||||
IsAdminChannel = x.IsAdminChannel == true,
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
public abstract Task Disconnect(CancellationToken cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract Task<IReadOnlyCollection<Channel>> MapChannels(IEnumerable<ChatChannel> channels, CancellationToken cancellationToken);
|
||||
public abstract Task<IReadOnlyCollection<ChatChannel>> MapChannels(IEnumerable<Api.Models.ChatChannel> channels, CancellationToken cancellationToken);
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<Message> NextMessage(CancellationToken cancellationToken)
|
||||
|
||||
+1
-2
@@ -2,10 +2,9 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Host.Components.Chat.Providers;
|
||||
using Tgstation.Server.Host.Core;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Chat
|
||||
namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
{
|
||||
/// <inheritdoc />
|
||||
sealed class ProviderFactory : IProviderFactory
|
||||
@@ -1,20 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Chat
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a chat message requested by DD
|
||||
/// </summary>
|
||||
sealed class Response
|
||||
{
|
||||
/// <summary>
|
||||
/// The message string
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of internal channel ids to send <see cref="Message"/> to
|
||||
/// </summary>
|
||||
public List<ulong> ChannelIds { get; set; }
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop.Bridge
|
||||
namespace Tgstation.Server.Host.Components.Interop
|
||||
{
|
||||
public sealed class ChatMessage
|
||||
{
|
||||
@@ -19,9 +19,9 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
public string Params { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Chat.User"/> that sent the command
|
||||
/// The <see cref="Chat.ChatUser"/> that sent the command
|
||||
/// </summary>
|
||||
public User User { get; }
|
||||
public ChatUser User { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ChatCommand"/> <see langword="class"/>.
|
||||
@@ -29,7 +29,7 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
/// <param name="user">The value of <see cref="User"/>.</param>
|
||||
/// <param name="command">The value of <see cref="Name"/>.</param>
|
||||
/// <param name="parameters">The value of <see cref="Parames"/>.</param>
|
||||
public ChatCommand(User user, string command, string parameters)
|
||||
public ChatCommand(ChatUser user, string command, string parameters)
|
||||
{
|
||||
User = user ?? throw new ArgumentNullException(nameof(user));
|
||||
Name = command ?? throw new ArgumentNullException(nameof(command));
|
||||
|
||||
@@ -5,13 +5,13 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
sealed class EventNotification
|
||||
{
|
||||
public EventType EventType { get; }
|
||||
public EventType Type { get; }
|
||||
|
||||
public IReadOnlyCollection<object> Parameters { get; }
|
||||
|
||||
public EventNotification(EventType eventType, IEnumerable<object> parameters = null)
|
||||
{
|
||||
EventType = eventType;
|
||||
Type = eventType;
|
||||
Parameters = parameters?.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
|
||||
namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
@@ -7,8 +6,8 @@ namespace Tgstation.Server.Host.Components.Interop.Topic
|
||||
{
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
public string CommandResponse { get; set; }
|
||||
public string CommandResponseMessage { get; set; }
|
||||
|
||||
public ICollection<Response> ChatResponses { get; set; }
|
||||
public ICollection<ChatMessage> ChatResponses { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,13 +447,13 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
if (result?.ChatResponses == null)
|
||||
return true;
|
||||
|
||||
await Task.WhenAll(result.ChatResponses.Select(x => Chat.SendMessage(x.Message, x.ChannelIds, cancellationToken))).ConfigureAwait(false);
|
||||
await Task.WhenAll(result.ChatResponses.Select(x => Chat.SendMessage(x.Text, x.ChannelIds, cancellationToken))).ConfigureAwait(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public async Task<string> HandleChatCommand(string commandName, string arguments, Chat.User sender, CancellationToken cancellationToken)
|
||||
public async Task<string> HandleChatCommand(string commandName, string arguments, Chat.ChatUser sender, CancellationToken cancellationToken)
|
||||
{
|
||||
using (await SemaphoreSlimContext.Lock(Semaphore, cancellationToken).ConfigureAwait(false))
|
||||
{
|
||||
@@ -467,7 +467,7 @@ namespace Tgstation.Server.Host.Components.Watchdog
|
||||
var activeServer = GetActiveController();
|
||||
var commandResult = await activeServer.SendCommand(command, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
return commandResult?.CommandResponse ??
|
||||
return commandResult?.CommandResponseMessage ??
|
||||
(commandResult == null
|
||||
? "ERROR: Bad topic exchange!"
|
||||
: "ERROR: Bad DMAPI response!");
|
||||
|
||||
@@ -27,6 +27,7 @@ using Tgstation.Server.Api.Models;
|
||||
using Tgstation.Server.Host.Components;
|
||||
using Tgstation.Server.Host.Components.Byond;
|
||||
using Tgstation.Server.Host.Components.Chat;
|
||||
using Tgstation.Server.Host.Components.Chat.Providers;
|
||||
using Tgstation.Server.Host.Components.Repository;
|
||||
using Tgstation.Server.Host.Components.Watchdog;
|
||||
using Tgstation.Server.Host.Configuration;
|
||||
|
||||
Reference in New Issue
Block a user