2024-05-20 01:35:33 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
2024-05-20 23:00:47 +00:00
|
|
|
|
namespace SharpChat.PacketsS2C {
|
|
|
|
|
public class MessageAddLogS2CPacket : SockChatTimedS2CPacket {
|
2024-05-20 01:35:33 +00:00
|
|
|
|
private readonly long UserId;
|
|
|
|
|
private readonly string UserName;
|
|
|
|
|
private readonly Colour UserColour;
|
|
|
|
|
private readonly int UserRank;
|
|
|
|
|
private readonly UserPermissions UserPerms;
|
|
|
|
|
private readonly string Body;
|
|
|
|
|
private readonly bool IsAction;
|
|
|
|
|
private readonly bool IsPrivate;
|
|
|
|
|
private readonly bool IsBroadcast; // this should be MessageBroadcastLogPacket
|
|
|
|
|
private readonly bool Notify;
|
|
|
|
|
|
2024-05-20 23:00:47 +00:00
|
|
|
|
public MessageAddLogS2CPacket(
|
2024-05-20 02:16:38 +00:00
|
|
|
|
long messageId,
|
|
|
|
|
DateTimeOffset timeStamp,
|
2024-05-20 01:35:33 +00:00
|
|
|
|
long userId,
|
|
|
|
|
string userName,
|
|
|
|
|
Colour userColour,
|
|
|
|
|
int userRank,
|
|
|
|
|
UserPermissions userPerms,
|
|
|
|
|
string body,
|
|
|
|
|
bool isAction,
|
|
|
|
|
bool isPrivate,
|
|
|
|
|
bool isBroadcast,
|
|
|
|
|
bool notify
|
2024-05-20 02:16:38 +00:00
|
|
|
|
) : base(messageId, timeStamp) {
|
2024-05-20 01:35:33 +00:00
|
|
|
|
UserId = userId < 0 ? -1 : userId;
|
|
|
|
|
UserName = userName;
|
|
|
|
|
UserColour = userColour;
|
|
|
|
|
UserRank = userRank;
|
|
|
|
|
UserPerms = userPerms;
|
|
|
|
|
Body = body;
|
|
|
|
|
IsAction = isAction;
|
|
|
|
|
IsPrivate = isPrivate;
|
|
|
|
|
IsBroadcast = isBroadcast;
|
|
|
|
|
Notify = notify;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Pack() {
|
|
|
|
|
string body = SockChatUtility.SanitiseMessageBody(Body);
|
|
|
|
|
if(IsAction)
|
|
|
|
|
body = string.Format("<i>{0}</i>", body);
|
|
|
|
|
|
|
|
|
|
if(IsBroadcast)
|
|
|
|
|
body = "0\fsay\f" + body;
|
|
|
|
|
|
|
|
|
|
string userPerms = UserId < 0 ? string.Empty : string.Format(
|
|
|
|
|
"{0} {1} {2} {3} {4}",
|
|
|
|
|
UserRank,
|
|
|
|
|
UserPerms.HasFlag(UserPermissions.KickUser) == true ? 1 : 0,
|
|
|
|
|
UserPerms.HasFlag(UserPermissions.ViewLogs) == true ? 1 : 0,
|
|
|
|
|
UserPerms.HasFlag(UserPermissions.SetOwnNickname) == true ? 1 : 0,
|
|
|
|
|
UserPerms.HasFlag(UserPermissions.CreateChannel) == true ? (
|
|
|
|
|
UserPerms.HasFlag(UserPermissions.SetChannelPermanent) == true ? 2 : 1
|
|
|
|
|
) : 0
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return string.Format(
|
|
|
|
|
"7\t1\t{0}\t{1}\t{2}\t{3}\t{4}\t{5}\t{6}\t{7}\t{8}{9}{10}{11}{12}",
|
2024-05-20 02:16:38 +00:00
|
|
|
|
TimeStamp.ToUnixTimeSeconds(),
|
2024-05-20 01:35:33 +00:00
|
|
|
|
UserId,
|
|
|
|
|
UserName,
|
|
|
|
|
UserColour,
|
|
|
|
|
userPerms,
|
|
|
|
|
body,
|
2024-05-20 02:16:38 +00:00
|
|
|
|
MessageId,
|
2024-05-20 01:35:33 +00:00
|
|
|
|
Notify ? 1 : 0,
|
|
|
|
|
1,
|
|
|
|
|
IsAction ? 1 : 0,
|
|
|
|
|
0,
|
|
|
|
|
IsAction ? 0 : 1,
|
|
|
|
|
IsPrivate ? 1 : 0
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|