sharp-chat/SharpChat.Common/Events/MessageCreateEvent.cs

35 lines
1.2 KiB
C#
Raw Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Messages;
using SharpChat.Sessions;
using SharpChat.Users;
namespace SharpChat.Events {
[Event(TYPE)]
public class MessageCreateEvent : Event {
public const string TYPE = @"message:create";
public long MessageId { get; }
public string Text { get; }
public bool IsAction { get; }
public string UserName { get; }
public Colour UserColour { get; }
public int UserRank { get; }
public string UserNickName { get; }
public UserPermissions UserPermissions { get; }
public MessageCreateEvent(ISession session, IMessage message)
: base(message.Channel, session) {
MessageId = message.MessageId;
Text = message.Text;
IsAction = message.IsAction;
UserName = message.Sender.UserName;
UserColour = message.Sender.Colour;
UserRank = message.Sender.Rank;
UserNickName = message.Sender is ILocalUser localUser && !string.IsNullOrWhiteSpace(localUser.NickName)
? localUser.NickName
: null;
UserPermissions = message.Sender.Permissions;
}
}
}