sharp-chat/SharpChat.Common/Messages/Message.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Channels;
using SharpChat.Users;
using System;
namespace SharpChat.Messages {
public class Message : IMessage {
public long MessageId { get; }
public IChannel Channel { get; }
public IUser Sender { get; }
public string Text { get; }
public bool IsAction { get; }
public DateTimeOffset Created { get; }
public DateTimeOffset? Edited { get; }
public bool IsEdited => Edited.HasValue;
public Message(
IChannel channel,
IUser sender,
string text,
bool isAction = false,
DateTimeOffset? created = null,
DateTimeOffset? edited = null
) {
MessageId = SharpId.Next();
Channel = channel ?? throw new ArgumentNullException(nameof(channel));
Sender = sender ?? throw new ArgumentNullException(nameof(sender));
Text = text ?? throw new ArgumentNullException(nameof(text));
IsAction = isAction;
Created = created ?? DateTimeOffset.Now;
Edited = edited;
}
}
}