2022-08-30 15:00:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat.Packet {
|
|
|
|
|
public class LegacyCommandResponse : ServerPacket {
|
|
|
|
|
public bool IsError { get; private set; }
|
|
|
|
|
public string StringId { get; private set; }
|
|
|
|
|
public IEnumerable<object> Arguments { get; private set; }
|
|
|
|
|
|
|
|
|
|
public LegacyCommandResponse(
|
|
|
|
|
string stringId,
|
|
|
|
|
bool isError = true,
|
|
|
|
|
params object[] args
|
|
|
|
|
) {
|
|
|
|
|
IsError = isError;
|
|
|
|
|
StringId = stringId;
|
|
|
|
|
Arguments = args;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<string> Pack() {
|
2023-02-07 15:01:56 +00:00
|
|
|
|
StringBuilder sb = new();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
|
2023-02-07 15:01:56 +00:00
|
|
|
|
if(StringId == LCR.WELCOME) {
|
2023-02-07 14:34:31 +00:00
|
|
|
|
sb.Append('7');
|
2022-08-30 15:00:58 +00:00
|
|
|
|
sb.Append('\t');
|
2023-02-07 14:34:31 +00:00
|
|
|
|
sb.Append('1');
|
2022-08-30 15:00:58 +00:00
|
|
|
|
sb.Append('\t');
|
|
|
|
|
sb.Append(DateTimeOffset.Now.ToUnixTimeSeconds());
|
|
|
|
|
sb.Append("\t-1\tChatBot\tinherit\t\t");
|
|
|
|
|
} else {
|
2023-02-07 14:34:31 +00:00
|
|
|
|
sb.Append('2');
|
2022-08-30 15:00:58 +00:00
|
|
|
|
sb.Append('\t');
|
|
|
|
|
sb.Append(DateTimeOffset.Now.ToUnixTimeSeconds());
|
|
|
|
|
sb.Append("\t-1\t");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.Append(IsError ? '1' : '0');
|
|
|
|
|
sb.Append('\f');
|
|
|
|
|
sb.Append(StringId == LCR.WELCOME ? LCR.BROADCAST : StringId);
|
|
|
|
|
|
2023-02-07 15:01:56 +00:00
|
|
|
|
if(Arguments?.Any() == true)
|
|
|
|
|
foreach(object arg in Arguments) {
|
2022-08-30 15:00:58 +00:00
|
|
|
|
sb.Append('\f');
|
|
|
|
|
sb.Append(arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sb.Append('\t');
|
|
|
|
|
|
2023-02-07 15:01:56 +00:00
|
|
|
|
if(StringId == LCR.WELCOME) {
|
2022-08-30 15:00:58 +00:00
|
|
|
|
sb.Append(StringId);
|
|
|
|
|
sb.Append("\t0");
|
|
|
|
|
} else
|
|
|
|
|
sb.Append(SequenceId);
|
|
|
|
|
|
|
|
|
|
sb.Append("\t10010");
|
|
|
|
|
/*sb.AppendFormat(
|
|
|
|
|
"\t1{0}0{1}{2}",
|
|
|
|
|
Flags.HasFlag(ChatMessageFlags.Action) ? '1' : '0',
|
|
|
|
|
Flags.HasFlag(ChatMessageFlags.Action) ? '0' : '1',
|
|
|
|
|
Flags.HasFlag(ChatMessageFlags.Private) ? '1' : '0'
|
|
|
|
|
);*/
|
|
|
|
|
|
|
|
|
|
yield return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Abbreviated class name because otherwise shit gets wide
|
|
|
|
|
public static class LCR {
|
2023-02-08 03:17:07 +00:00
|
|
|
|
public const string GENERIC_ERROR = "generr";
|
|
|
|
|
public const string COMMAND_NOT_FOUND = "nocmd";
|
|
|
|
|
public const string COMMAND_NOT_ALLOWED = "cmdna";
|
|
|
|
|
public const string COMMAND_FORMAT_ERROR = "cmderr";
|
|
|
|
|
public const string WELCOME = "welcome";
|
|
|
|
|
public const string BROADCAST = "say";
|
|
|
|
|
public const string IP_ADDRESS = "ipaddr";
|
|
|
|
|
public const string USER_NOT_FOUND = "usernf";
|
|
|
|
|
public const string NAME_IN_USE = "nameinuse";
|
|
|
|
|
public const string CHANNEL_INSUFFICIENT_HIERARCHY = "ipchan";
|
|
|
|
|
public const string CHANNEL_INVALID_PASSWORD = "ipwchan";
|
|
|
|
|
public const string CHANNEL_NOT_FOUND = "nochan";
|
|
|
|
|
public const string CHANNEL_ALREADY_EXISTS = "nischan";
|
2022-08-30 15:00:58 +00:00
|
|
|
|
public const string CHANNEL_NAME_INVALID = "inchan";
|
2023-02-08 03:17:07 +00:00
|
|
|
|
public const string CHANNEL_CREATED = "crchan";
|
|
|
|
|
public const string CHANNEL_DELETE_FAILED = "ndchan";
|
|
|
|
|
public const string CHANNEL_DELETED = "delchan";
|
|
|
|
|
public const string CHANNEL_PASSWORD_CHANGED = "cpwdchan";
|
|
|
|
|
public const string CHANNEL_HIERARCHY_CHANGED = "cprivchan";
|
|
|
|
|
public const string USERS_LISTING_ERROR = "whoerr";
|
|
|
|
|
public const string USERS_LISTING_CHANNEL = "whochan";
|
|
|
|
|
public const string USERS_LISTING_SERVER = "who";
|
|
|
|
|
public const string INSUFFICIENT_HIERARCHY = "rankerr";
|
|
|
|
|
public const string MESSAGE_DELETE_ERROR = "delerr";
|
|
|
|
|
public const string KICK_NOT_ALLOWED = "kickna";
|
|
|
|
|
public const string USER_NOT_BANNED = "notban";
|
|
|
|
|
public const string USER_UNBANNED = "unban";
|
2023-02-22 00:28:53 +00:00
|
|
|
|
public const string FLOOD_WARN = "flwarn";
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|