refactor!: extract interface for Avatar

This commit is contained in:
Oliver Booth 2024-03-17 12:56:28 +00:00
parent 05b53da5a4
commit a169346f53
Signed by: oliverbooth
GPG Key ID: E60B570D1B7557B5
18 changed files with 235 additions and 52 deletions

View File

@ -45,7 +45,7 @@ Console.WriteLine(@"Entering world");
World world = await client.EnterAsync("Mutation");
Console.WriteLine(@"Entered world!");
Avatar avatar = client.CurrentAvatar!;
IAvatar avatar = client.CurrentAvatar!;
Console.WriteLine($@"My name is {avatar.Name} and I am at {avatar.Location}");
Console.WriteLine($@"Entered {world.Name} with size {world.Size}");

View File

@ -10,7 +10,7 @@ namespace VpSharp.Entities;
/// <summary>
/// Represents an avatar within a world.
/// </summary>
public sealed class Avatar : IEquatable<Avatar>
public sealed class Avatar : IEquatable<Avatar>, IAvatar
{
private readonly VirtualParadiseClient _client;
private User? _user;
@ -233,7 +233,7 @@ public sealed class Avatar : IEquatable<Avatar>
throw new ArgumentException(ExceptionMessages.ValueCannotBeEmpty, nameof(message));
}
Avatar avatar;
IAvatar avatar;
lock (_client.Lock)
{

View File

@ -0,0 +1,184 @@
using System.Drawing;
namespace VpSharp.Entities;
public interface IAvatar
{
/// <summary>
/// Gets the details of the application this avatar is using.
/// </summary>
/// <value>The avatar's application details.</value>
Application Application { get; }
/// <summary>
/// Gets a value indicating whether this avatar is a bot.
/// </summary>
/// <value><see langword="true" /> if this avatar is a bot; otherwise, <see langword="false" />.</value>
bool IsBot { get; }
/// <summary>
/// Gets the location of this avatar.
/// </summary>
/// <value>The location of this avatar.</value>
Location Location { get; }
/// <summary>
/// Gets the name of this avatar.
/// </summary>
/// <value>The name of this avatar.</value>
string Name { get; }
/// <summary>
/// Gets the session ID of this avatar.
/// </summary>
/// <value>The session ID.</value>
int Session { get; }
/// <summary>
/// Gets the type of this avatar.
/// </summary>
/// <value>The type of this avatar.</value>
int Type { get; }
/// <summary>
/// Gets the user ID associated with this avatar.
/// </summary>
/// <value>The user ID.</value>
int UserId { get; }
/// <summary>
/// Clicks this avatar.
/// </summary>
/// <param name="clickPoint">The position at which the avatar should be clicked.</param>
/// <exception cref="InvalidOperationException">
/// <para>The action cannot be performed on the client's current avatar.</para>
/// -or-
/// <para>An attempt was made to click an avatar outside of a world.</para>
/// </exception>
Task ClickAsync(Vector3d? clickPoint = null);
/// <summary>
/// Determines if two <see cref="Avatar" /> instances are equal.
/// </summary>
/// <param name="other">The other instance.</param>
/// <returns>
/// <see langword="true" /> if this instance is equal to <paramref name="other" />; otherwise, <see langword="false" />.
/// </returns>
bool Equals(Avatar? other);
/// <summary>
/// Gets the user associated with this avatar.
/// </summary>
/// <returns>The user.</returns>
Task<User> GetUserAsync();
/// <summary>
/// Sends a console message to the avatar with no name.
/// </summary>
/// <param name="message">The message to send.</param>
/// <param name="fontStyle">The font style of the message.</param>
/// <param name="color">The text color of the message.</param>
/// <returns>The message which was sent.</returns>
/// <exception cref="ArgumentNullException"><paramref name="message" /> is <see langword="null" />.</exception>
/// <exception cref="InvalidOperationException">
/// <para>An attempt was made to send a message while not connected to a world.</para>
/// -or-
/// <para>An attempt was made to send a message to an avatar that is not in the world.</para>
/// </exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="message" /> is empty, or consists of only whitespace.</para>
/// -or-
/// <para><paramref name="message" /> is too long to send.</para>
/// </exception>
Task<Message> SendMessageAsync(string message, FontStyle fontStyle, Color color);
/// <summary>
/// Sends a console message to the avatar.
/// </summary>
/// <param name="name">The apparent author of the message.</param>
/// <param name="message">The message to send.</param>
/// <param name="fontStyle">The font style of the message.</param>
/// <param name="color">The text color of the message.</param>
/// <returns>The message which was sent.</returns>
/// <exception cref="ArgumentNullException"><paramref name="message" /> is <see langword="null" />.</exception>
/// <exception cref="InvalidOperationException">
/// <para>An attempt was made to send a message while not connected to a world.</para>
/// -or-
/// <para>An attempt was made to send a message to an avatar that is not in the world.</para>
/// </exception>
/// <exception cref="ArgumentException">
/// <para><paramref name="message" /> is empty, or consists of only whitespace.</para>
/// -or-
/// <para><paramref name="message" /> is too long to send.</para>
/// </exception>
/// <remarks>Passing <see langword="null" /> to <paramref name="name" /> will hide the name from the recipient.</remarks>
Task<Message> SendMessageAsync(string? name, string message, FontStyle fontStyle, Color color);
/// <summary>
/// Sends a URI to this avatar.
/// </summary>
/// <param name="uri">The URI to send.</param>
/// <param name="target">The URL target. See <see cref="UriTarget" /> for more information.</param>
/// <exception cref="InvalidOperationException">The action cannot be performed on the client's current avatar.</exception>
/// <exception cref="ArgumentNullException"><paramref name="uri" /> is <see langword="null" />.</exception>
Task SendUriAsync(Uri uri, UriTarget target = UriTarget.Browser);
/// <summary>
/// Modifies the world settings for this avatar.
/// </summary>
/// <param name="action">The builder which defines parameters to change.</param>
/// <exception cref="ArgumentNullException"><paramref name="action" /> is <see langword="null" />.</exception>
/// <exception cref="UnauthorizedAccessException">The client does not have permission to modify world settings.</exception>
Task SendWorldSettings(Action<WorldSettingsBuilder> action);
/// <summary>
/// Teleports the avatar to another world.
/// </summary>
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
/// <param name="position">The position to which this avatar should be teleported.</param>
/// <exception cref="ArgumentNullException"><paramref name="world" /> is <see langword="null" />.</exception>
Task TeleportAsync(World world, Vector3d position);
/// <summary>
/// Teleports the avatar to another world.
/// </summary>
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
/// <param name="position">The position to which this avatar should be teleported.</param>
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
/// <exception cref="ArgumentNullException"><paramref name="world" /> is <see langword="null" />.</exception>
Task TeleportAsync(World world, Vector3d position, Rotation rotation);
/// <summary>
/// Teleports the avatar to another world.
/// </summary>
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
/// <param name="position">The position to which this avatar should be teleported.</param>
Task TeleportAsync(string world, Vector3d position);
/// <summary>
/// Teleports the avatar to another world.
/// </summary>
/// <param name="world">The name of the world to which this avatar should be teleported.</param>
/// <param name="position">The position to which this avatar should be teleported.</param>
/// <param name="rotation">The rotation to which this avatar should be teleported.</param>
Task TeleportAsync(string world, Vector3d position, Rotation rotation);
/// <summary>
/// Teleports the avatar to a new position within the current world.
/// </summary>
/// <param name="position">The position to which this avatar should be teleported.</param>
Task TeleportAsync(Vector3d position);
/// <summary>
/// Teleports the avatar to a new position and rotation within the current world.
/// </summary>
/// <param name="position">The position to which this avatar should be teleported.</param>
/// <param name="rotation">The rotation to which this avatar should be teleported</param>
Task TeleportAsync(Vector3d position, Rotation rotation);
/// <summary>
/// Teleports this avatar to a new location, which may or may not be a new world.
/// </summary>
/// <param name="location">The location to which this avatar should be teleported.</param>
Task TeleportAsync(Location location);
}

View File

@ -11,7 +11,7 @@ public sealed class Message
MessageType type,
string? name,
string content,
Avatar author,
IAvatar author,
FontStyle style,
Color color)
{
@ -27,7 +27,7 @@ public sealed class Message
/// Gets the message author.
/// </summary>
/// <value>The message author.</value>
public Avatar Author { get; }
public IAvatar Author { get; }
/// <summary>
/// Gets the message content.

View File

@ -13,7 +13,7 @@ public sealed class AvatarClickedEventArgs : EventArgs
/// <param name="avatar">The avatar responsible for the click.</param>
/// <param name="clickedAvatar">The clicked avatar.</param>
/// <param name="clickPoint">The click point.</param>
public AvatarClickedEventArgs(Avatar avatar, Avatar clickedAvatar, Vector3d clickPoint)
public AvatarClickedEventArgs(IAvatar avatar, IAvatar clickedAvatar, Vector3d clickPoint)
{
Avatar = avatar;
ClickedAvatar = clickedAvatar;
@ -24,13 +24,13 @@ public sealed class AvatarClickedEventArgs : EventArgs
/// Gets the avatar responsible for the click.
/// </summary>
/// <value>The avatar responsible for the click.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the clicked avatar.
/// </summary>
/// <value>The clicked avatar.</value>
public Avatar ClickedAvatar { get; }
public IAvatar ClickedAvatar { get; }
/// <summary>
/// Gets the point at which the avatar clicked the object.

View File

@ -13,7 +13,7 @@ public sealed class AvatarMovedEventArgs : EventArgs
/// <param name="avatar">The avatar whose type was changed.</param>
/// <param name="locationAfter">The avatar's new location.</param>
/// <param name="locationBefore">The avatar's old location.</param>
public AvatarMovedEventArgs(Avatar avatar, Location locationAfter, Location? locationBefore)
public AvatarMovedEventArgs(IAvatar avatar, Location locationAfter, Location? locationBefore)
{
Avatar = avatar;
LocationAfter = locationAfter;
@ -24,7 +24,7 @@ public sealed class AvatarMovedEventArgs : EventArgs
/// Gets the avatar whose location was changed.
/// </summary>
/// <value>The avatar whose location was changed.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the avatar's location after the change.

View File

@ -13,7 +13,7 @@ public sealed class AvatarTypeChangedEventArgs : EventArgs
/// <param name="avatar">The avatar whose type was changed.</param>
/// <param name="typeAfter">The avatar's new type.</param>
/// <param name="typeBefore">The avatar's old type.</param>
public AvatarTypeChangedEventArgs(Avatar avatar, int typeAfter, int? typeBefore)
public AvatarTypeChangedEventArgs(IAvatar avatar, int typeAfter, int? typeBefore)
{
Avatar = avatar;
TypeAfter = typeAfter;
@ -24,7 +24,7 @@ public sealed class AvatarTypeChangedEventArgs : EventArgs
/// Gets the avatar whose type was changed.
/// </summary>
/// <value>The avatar whose type was changed.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the avatar's type after the change.

View File

@ -13,7 +13,7 @@ public sealed class ObjectBumpEventArgs : EventArgs
/// <param name="avatar">The avatar.</param>
/// <param name="bumpedObject">The bumped object.</param>
/// <param name="phase">The bump phase.</param>
public ObjectBumpEventArgs(Avatar avatar, VirtualParadiseObject bumpedObject, BumpPhase phase)
public ObjectBumpEventArgs(IAvatar avatar, VirtualParadiseObject bumpedObject, BumpPhase phase)
{
Avatar = avatar;
BumpedObject = bumpedObject;
@ -24,7 +24,7 @@ public sealed class ObjectBumpEventArgs : EventArgs
/// Gets the avatar responsible for the bump.
/// </summary>
/// <value>The avatar responsible for the bump.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the object to which this event pertains.

View File

@ -14,7 +14,7 @@ public sealed class ObjectChangedEventArgs : EventArgs
/// <param name="objectBefore">The state of the object prior to the change.</param>
/// <param name="objectAfter">The object which was changed, containing updated values.</param>
public ObjectChangedEventArgs(
Avatar avatar,
IAvatar avatar,
VirtualParadiseObject? objectBefore,
VirtualParadiseObject objectAfter)
{
@ -27,7 +27,7 @@ public sealed class ObjectChangedEventArgs : EventArgs
/// Gets the avatar which changed the object.
/// </summary>
/// <value>The avatar which changed the object.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the object which was changed.

View File

@ -14,7 +14,7 @@ public sealed class ObjectClickedEventArgs : EventArgs
/// <param name="clickedObject">The clicked object.</param>
/// <param name="clickPoint">The click point.</param>
public ObjectClickedEventArgs(
Avatar avatar,
IAvatar avatar,
VirtualParadiseObject clickedObject,
Vector3d clickPoint)
{
@ -27,7 +27,7 @@ public sealed class ObjectClickedEventArgs : EventArgs
/// Gets the avatar responsible for the click.
/// </summary>
/// <value>The avatar responsible for the click.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the clicked object.

View File

@ -12,7 +12,7 @@ public sealed class ObjectCreatedEventArgs : EventArgs
/// </summary>
/// <param name="avatar">The avatar responsible for the object being created.</param>
/// <param name="createdObject">The created object.</param>
public ObjectCreatedEventArgs(Avatar avatar, VirtualParadiseObject createdObject)
public ObjectCreatedEventArgs(IAvatar avatar, VirtualParadiseObject createdObject)
{
Avatar = avatar;
CreatedObject = createdObject;
@ -22,7 +22,7 @@ public sealed class ObjectCreatedEventArgs : EventArgs
/// Gets the avatar responsible for the object being created.
/// </summary>
/// <value>The avatar responsible for the object being created.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the object which was created.

View File

@ -13,7 +13,7 @@ public sealed class ObjectDeletedEventArgs : EventArgs
/// <param name="avatar">The avatar responsible for the object being deleted.</param>
/// <param name="objectId">The ID of the deleted object.</param>
/// <param name="deletedObject">The deleted object.</param>
public ObjectDeletedEventArgs(Avatar avatar, int objectId, VirtualParadiseObject deletedObject)
public ObjectDeletedEventArgs(IAvatar avatar, int objectId, VirtualParadiseObject deletedObject)
{
Avatar = avatar;
ObjectId = objectId;
@ -24,7 +24,7 @@ public sealed class ObjectDeletedEventArgs : EventArgs
/// Gets the avatar responsible for the object being deleted.
/// </summary>
/// <value>The avatar responsible for the object being deleted.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the object which was deleted.

View File

@ -12,7 +12,7 @@ public sealed class TeleportedEventArgs : EventArgs
/// </summary>
/// <param name="avatar">The avatar which initiated the teleport.</param>
/// <param name="location">The target location of the teleport.</param>
public TeleportedEventArgs(Avatar avatar, Location location)
public TeleportedEventArgs(IAvatar avatar, Location location)
{
Avatar = avatar;
Location = location;
@ -22,7 +22,7 @@ public sealed class TeleportedEventArgs : EventArgs
/// Gets the avatar which initiated the teleport.
/// </summary>
/// <value>The avatar which initiated the teleport.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the target location of the teleport.

View File

@ -13,7 +13,7 @@ public sealed class UriReceivedEventArgs : EventArgs
/// <param name="uri">The received URI.</param>
/// <param name="target">The URI target.</param>
/// <param name="avatar">The avatar who sent the URI.</param>
public UriReceivedEventArgs(Uri uri, UriTarget target, Avatar avatar)
public UriReceivedEventArgs(Uri uri, UriTarget target, IAvatar avatar)
{
Uri = uri;
Target = target;
@ -24,7 +24,7 @@ public sealed class UriReceivedEventArgs : EventArgs
/// Gets the avatar who sent the URI.
/// </summary>
/// <value>The avatar who sent the URI.</value>
public Avatar Avatar { get; }
public IAvatar Avatar { get; }
/// <summary>
/// Gets the URI target.

View File

@ -20,7 +20,7 @@ public sealed partial class VirtualParadiseClient
/// The avatar whose session is equal to <paramref name="session" />, or <see langword="null" /> if no match was
/// found.
/// </returns>
public Avatar? GetAvatar(int session)
public IAvatar? GetAvatar(int session)
{
_avatars.TryGetValue(session, out Avatar? avatar);
return avatar;

View File

@ -7,8 +7,8 @@ namespace VpSharp;
public sealed partial class VirtualParadiseClient
{
private readonly Subject<AvatarClickedEventArgs> _avatarClicked = new();
private readonly Subject<Avatar> _avatarJoined = new();
private readonly Subject<Avatar> _avatarLeft = new();
private readonly Subject<IAvatar> _avatarJoined = new();
private readonly Subject<IAvatar> _avatarLeft = new();
private readonly Subject<AvatarMovedEventArgs> _avatarMoved = new();
private readonly Subject<AvatarTypeChangedEventArgs> _avatarTypeChanged = new();
private readonly Subject<InviteRequest> _inviteRequestReceived = new();
@ -35,7 +35,7 @@ public sealed partial class VirtualParadiseClient
/// <summary>
/// Occurs when an avatar has entered the vicinity of the client.
/// </summary>
public IObservable<Avatar> AvatarJoined
public IObservable<IAvatar> AvatarJoined
{
get => _avatarJoined;
}
@ -43,7 +43,7 @@ public sealed partial class VirtualParadiseClient
/// <summary>
/// Occurs when an avatar has left the vicinity of the client.
/// </summary>
public IObservable<Avatar> AvatarLeft
public IObservable<IAvatar> AvatarLeft
{
get => _avatarLeft;
}

View File

@ -74,7 +74,7 @@ public sealed partial class VirtualParadiseClient
style = (FontStyle)vp_int(sender, IntegerAttribute.ChatEffects);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
message = new Message((MessageType)type, name, content, avatar, style, color);
}
@ -115,7 +115,7 @@ public sealed partial class VirtualParadiseClient
rotation = Rotation.CreateFromTiltYawRoll(pitch, yaw, 0);
}
Avatar avatar = GetAvatar(session)!;
var avatar = (Avatar)GetAvatar(session)!;
if (type != avatar.Type)
{
int oldType = avatar.Type;
@ -145,7 +145,7 @@ public sealed partial class VirtualParadiseClient
session = vp_int(sender, IntegerAttribute.AvatarSession);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
_avatars.TryRemove(session, out Avatar _);
_avatarLeft.OnNext(avatar);
}
@ -173,7 +173,7 @@ public sealed partial class VirtualParadiseClient
}
else
{
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
var args = new ObjectCreatedEventArgs(avatar, virtualParadiseObject);
_objectCreated.OnNext(args);
}
@ -190,7 +190,7 @@ public sealed partial class VirtualParadiseClient
session = vp_int(sender, IntegerAttribute.AvatarSession);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
VirtualParadiseObject? cachedObject = null;
if (_objects.TryGetValue(objectId, out VirtualParadiseObject? virtualParadiseObject))
@ -226,7 +226,7 @@ public sealed partial class VirtualParadiseClient
session = vp_int(sender, IntegerAttribute.AvatarSession);
}
Avatar? avatar = GetAvatar(session);
IAvatar avatar = GetAvatar(session)!;
VirtualParadiseObject? virtualParadiseObject;
try
@ -240,7 +240,7 @@ public sealed partial class VirtualParadiseClient
_objects.TryRemove(objectId, out VirtualParadiseObject _);
var args = new ObjectDeletedEventArgs(avatar!, objectId, virtualParadiseObject!);
var args = new ObjectDeletedEventArgs(avatar, objectId, virtualParadiseObject!);
_objectDeleted.OnNext(args);
}
@ -261,7 +261,7 @@ public sealed partial class VirtualParadiseClient
clickPoint = new Vector3d(x, y, z);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
try
{
VirtualParadiseObject virtualParadiseObject = await GetObjectAsync(objectId).ConfigureAwait(false);
@ -423,8 +423,8 @@ public sealed partial class VirtualParadiseClient
clickPoint = new Vector3d(x, y, z);
}
Avatar avatar = GetAvatar(session)!;
Avatar clickedAvatar = GetAvatar(clickedSession)!;
IAvatar avatar = GetAvatar(session)!;
IAvatar clickedAvatar = GetAvatar(clickedSession)!;
var args = new AvatarClickedEventArgs(avatar, clickedAvatar, clickPoint);
_avatarClicked.OnNext(args);
}
@ -457,8 +457,8 @@ public sealed partial class VirtualParadiseClient
: await GetWorldAsync(worldName).ConfigureAwait(false))!;
var location = new Location(world, position, rotation);
CurrentAvatar!.Location = location;
Avatar avatar = GetAvatar(session)!;
((Avatar)CurrentAvatar!).Location = location;
IAvatar avatar = GetAvatar(session)!;
var args = new TeleportedEventArgs(avatar, location);
_teleported.OnNext(args);
}
@ -474,7 +474,7 @@ public sealed partial class VirtualParadiseClient
objectId = vp_int(sender, IntegerAttribute.ObjectId);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
try
{
var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false);
@ -505,7 +505,7 @@ public sealed partial class VirtualParadiseClient
return;
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
var uri = new Uri(url);
var args = new UriReceivedEventArgs(uri, target, avatar);
_uriReceived.OnNext(args);
@ -522,7 +522,7 @@ public sealed partial class VirtualParadiseClient
objectId = vp_int(sender, IntegerAttribute.ObjectId);
}
Avatar avatar = GetAvatar(session)!;
IAvatar avatar = GetAvatar(session)!;
try
{
var vpObject = await GetObjectAsync(objectId).ConfigureAwait(false);

View File

@ -66,7 +66,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
/// Gets a read-only view of the cached avatars.
/// </summary>
/// <value>The cached avatars.</value>
public IReadOnlyList<Avatar> Avatars
public IReadOnlyList<IAvatar> Avatars
{
get => _avatars.Values.ToArray();
}
@ -77,7 +77,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
/// <value>
/// An instance of <see cref="Avatar" />, or <see langword="null" /> if this client is not in a world.
/// </value>
public Avatar? CurrentAvatar { get; internal set; }
public IAvatar? CurrentAvatar { get; internal set; }
/// <summary>
/// Gets the current user to which this client is logged in.
@ -399,7 +399,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
if (CurrentAvatar is not null)
{
// TODO why is this here? we reassign CurrentAvatar right below!
CurrentAvatar.Location = new Location(world);
((Avatar)CurrentAvatar).Location = new Location(world);
}
world.Size = new Size(size, size);
@ -593,7 +593,7 @@ public sealed partial class VirtualParadiseClient : IDisposable
}
}
Avatar? avatar = CurrentAvatar;
IAvatar? avatar = CurrentAvatar;
return Task.FromResult(new Message(
MessageType.ChatMessage,
avatar!.Name,
@ -680,12 +680,11 @@ public sealed partial class VirtualParadiseClient : IDisposable
}
}
Avatar avatar = CurrentAvatar!;
return Task.FromResult(new Message(
MessageType.ConsoleMessage,
name,
message,
avatar,
CurrentAvatar!,
fontStyle,
color
));