From 903e39ab76ddaeff227cfe664ee4a10be4ccd6a3 Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 23 Jul 2023 21:36:22 +0000 Subject: [PATCH] Removed any remaining references to silencing. --- Protocol.md | 78 ------------------- SharpChat/ChatUserPermissions.cs | 2 +- SharpChat/Commands/SilenceApplyCommand.cs | 56 ------------- SharpChat/Commands/SilenceRevokeCommand.cs | 40 ---------- SharpChat/Misuzu/MisuzuAuthInfo.cs | 3 - SharpChat/Packet/LegacyCommandResponse.cs | 9 --- .../PacketHandlers/SendMessageHandler.cs | 3 +- SharpChat/SockChatServer.cs | 2 - 8 files changed, 2 insertions(+), 191 deletions(-) delete mode 100644 SharpChat/Commands/SilenceApplyCommand.cs delete mode 100644 SharpChat/Commands/SilenceRevokeCommand.cs diff --git a/Protocol.md b/Protocol.md index 96918d0..64afe52 100644 --- a/Protocol.md +++ b/Protocol.md @@ -762,28 +762,6 @@ Just echo whatever is specified in the first argument. - `string`: Message to be broadcast. -#### `silence`: Silence notice -Informs the client that they've been silenced. - - -#### `unsil`: Silence revocation notice -Informs the client that their silence has been revoked. - - -#### `silok`: Silence confirmation -Informs the client that they have successfully silenced another user. - -##### Arguments - - `string`: Username of the user. - - -#### `usilok`: Silence revocation confirmation -Informs the client that they have successfully revoked another user's silence. - -##### Arguments - - `string`: Username of the user. - - #### `flwarn`: Flood protection warning Informs the client that they are risking getting kicked for flood protection (spam) if they continue sending messages at the same rate. @@ -1027,26 +1005,6 @@ Informs the client that they are not allowed to edit a channel. Informs the client that they are not allowed to delete a message. -#### `silerr`: Already silenced -Informs the client that the user they attempted to silence has already been silenced. - - -#### `usilerr`: Not silenced -Informs the client that the user whose silence they attempted to revoke has not been silenced. - - -#### `silperr`: Silence permission error -Informs the client that they are not allowed to silence the other user. - - -#### `usilperr`: Silence revocation permission error -Informs the client that they are not allowed to revoke the silence on the other user. - - -#### `silself`: Self silence -Informs the client that they are not allowed to silence themselves. - - ## Commands Actions sent through messages prefixed with `/`. Arguments are described as `[name]`, optional arguments as `[name?]`. The `.` character is ignored in command names (replaced by nothing). @@ -1330,42 +1288,6 @@ Retrieves a list of banned users and IP addresses. - `banlist`: The list of banned users and IP addresses. -### `/silence`: Silence a user -Silences a user. If the time argument is not specified, the silence is indefinite. - -#### Format -``` -/silence [username] [time?] -``` - -#### Responses - - `cmdna`: The client is not allowed to silence users. - - `usernf`: The target user could not be found on the server. - - `silself`: The client tried to silence themselves. - - `silperr`: The target user has a higher rank that the client. - - `silerr`: The target user is already silenced. - - `cmderr`: The time argument is formatted incorrectly. - - `silence`: Informs the target user that they have been silenced. - - `silok`: The target has been successfully silenced. - - -### `/unsilence`: Revokes a user silence -Revokes a user's silenced status. - -#### Format -``` -/unsilence [username] -``` - -#### Responses - - `cmdna`: The client is not allowed to revoke silences. - - `usernf`: The target user could not be found. - - `usilperr`: The target user has a higher rank than the client. - - `usilerr`: The target user isn't silenced. - - `unsil`: Informs the target user that their silenced status has been revoked. - - `usilok`: The silenced status placed on the target has been successfully revoked. - - ### `/ip`: Retrieve IP addresses Retrieves a user's IP addresses. If the user has multiple connections, multiple `ipaddr` responses may be sent. diff --git a/SharpChat/ChatUserPermissions.cs b/SharpChat/ChatUserPermissions.cs index a4f7fee..ba5771f 100644 --- a/SharpChat/ChatUserPermissions.cs +++ b/SharpChat/ChatUserPermissions.cs @@ -5,7 +5,7 @@ namespace SharpChat { public enum ChatUserPermissions : int { KickUser = 0x00000001, BanUser = 0x00000002, - SilenceUser = 0x00000004, + //SilenceUser = 0x00000004, Broadcast = 0x00000008, SetOwnNickname = 0x00000010, SetOthersNickname = 0x00000020, diff --git a/SharpChat/Commands/SilenceApplyCommand.cs b/SharpChat/Commands/SilenceApplyCommand.cs deleted file mode 100644 index afc9567..0000000 --- a/SharpChat/Commands/SilenceApplyCommand.cs +++ /dev/null @@ -1,56 +0,0 @@ -using SharpChat.Packet; -using System; -using System.Linq; - -namespace SharpChat.Commands { - public class SilenceApplyCommand : IChatCommand { - public bool IsMatch(ChatCommandContext ctx) { - return ctx.NameEquals("silence"); - } - - public void Dispatch(ChatCommandContext ctx) { - if(!ctx.User.Can(ChatUserPermissions.SilenceUser)) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); - return; - } - - string silUserStr = ctx.Args.FirstOrDefault(); - ChatUser silUser; - - if(string.IsNullOrWhiteSpace(silUserStr) || (silUser = ctx.Chat.Users.FirstOrDefault(u => u.NameEquals(silUserStr))) == null) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.USER_NOT_FOUND, true, silUserStr ?? "User")); - return; - } - - if(silUser == ctx.User) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.SILENCE_SELF)); - return; - } - - if(silUser.Rank >= ctx.User.Rank) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.SILENCE_HIERARCHY)); - return; - } - - if(RNG.Next() > 1 /*silUser.IsSilenced*/) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.SILENCE_ALREADY)); - return; - } - - DateTimeOffset silenceUntil = DateTimeOffset.MaxValue; - - if(ctx.Args.Length > 1) { - if(!double.TryParse(ctx.Args.ElementAt(1), out double silenceSeconds)) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.COMMAND_FORMAT_ERROR)); - return; - } - - silenceUntil = DateTimeOffset.UtcNow.AddSeconds(silenceSeconds); - } - - //silUser.SilencedUntil = silenceUntil; - ctx.Chat.SendTo(silUser, new LegacyCommandResponse(LCR.SILENCED, false)); - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.TARGET_SILENCED, false, silUser.LegacyName)); - } - } -} diff --git a/SharpChat/Commands/SilenceRevokeCommand.cs b/SharpChat/Commands/SilenceRevokeCommand.cs deleted file mode 100644 index 98c3fe3..0000000 --- a/SharpChat/Commands/SilenceRevokeCommand.cs +++ /dev/null @@ -1,40 +0,0 @@ -using SharpChat.Packet; -using System; -using System.Linq; - -namespace SharpChat.Commands { - public class SilenceRevokeCommand : IChatCommand { - public bool IsMatch(ChatCommandContext ctx) { - return ctx.NameEquals("unsilence"); - } - - public void Dispatch(ChatCommandContext ctx) { - if(!ctx.User.Can(ChatUserPermissions.SilenceUser)) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.COMMAND_NOT_ALLOWED, true, $"/{ctx.Name}")); - return; - } - - string unsilUserStr = ctx.Args.FirstOrDefault(); - ChatUser unsilUser; - - if(string.IsNullOrWhiteSpace(unsilUserStr) || (unsilUser = ctx.Chat.Users.FirstOrDefault(u => u.NameEquals(unsilUserStr))) == null) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.USER_NOT_FOUND, true, unsilUserStr ?? "User")); - return; - } - - if(unsilUser.Rank >= ctx.User.Rank) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.UNSILENCE_HIERARCHY)); - return; - } - - if(RNG.Next() > 1 /*!unsilUser.IsSilenced*/) { - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.NOT_SILENCED)); - return; - } - - //unsilUser.SilencedUntil = DateTimeOffset.MinValue; - ctx.Chat.SendTo(unsilUser, new LegacyCommandResponse(LCR.UNSILENCED, false)); - ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.TARGET_UNSILENCED, false, unsilUser.LegacyName)); - } - } -} diff --git a/SharpChat/Misuzu/MisuzuAuthInfo.cs b/SharpChat/Misuzu/MisuzuAuthInfo.cs index ad4a3a2..3750aef 100644 --- a/SharpChat/Misuzu/MisuzuAuthInfo.cs +++ b/SharpChat/Misuzu/MisuzuAuthInfo.cs @@ -23,9 +23,6 @@ namespace SharpChat.Misuzu { [JsonPropertyName("hierarchy")] public int Rank { get; set; } - [JsonPropertyName("is_silenced")] - public DateTimeOffset SilencedUntil { get; set; } - [JsonPropertyName("perms")] public ChatUserPermissions Permissions { get; set; } } diff --git a/SharpChat/Packet/LegacyCommandResponse.cs b/SharpChat/Packet/LegacyCommandResponse.cs index 5605ee4..eaf14e8 100644 --- a/SharpChat/Packet/LegacyCommandResponse.cs +++ b/SharpChat/Packet/LegacyCommandResponse.cs @@ -76,15 +76,6 @@ namespace SharpChat.Packet { public const string BROADCAST = "say"; public const string IP_ADDRESS = "ipaddr"; public const string USER_NOT_FOUND = "usernf"; - public const string SILENCE_SELF = "silself"; - public const string SILENCE_HIERARCHY = "silperr"; - public const string SILENCE_ALREADY = "silerr"; - public const string TARGET_SILENCED = "silok"; - public const string SILENCED = "silence"; - public const string UNSILENCED = "unsil"; - public const string TARGET_UNSILENCED = "usilok"; - public const string NOT_SILENCED = "usilerr"; - public const string UNSILENCE_HIERARCHY = "usilperr"; public const string NAME_IN_USE = "nameinuse"; public const string CHANNEL_INSUFFICIENT_HIERARCHY = "ipchan"; public const string CHANNEL_INVALID_PASSWORD = "ipwchan"; diff --git a/SharpChat/PacketHandlers/SendMessageHandler.cs b/SharpChat/PacketHandlers/SendMessageHandler.cs index 7f7c50e..b3b9f82 100644 --- a/SharpChat/PacketHandlers/SendMessageHandler.cs +++ b/SharpChat/PacketHandlers/SendMessageHandler.cs @@ -48,8 +48,7 @@ namespace SharpChat.PacketHandlers ctx.Chat.ContextAccess.Wait(); try { if(!ctx.Chat.UserLastChannel.TryGetValue(user.UserId, out ChatChannel channel) - && !ctx.Chat.IsInChannel(user, channel) - /*|| (user.IsSilenced && !user.Can(ChatUserPermissions.SilenceUser))*/) + && !ctx.Chat.IsInChannel(user, channel)) return; if(user.Status != ChatUserStatus.Online) diff --git a/SharpChat/SockChatServer.cs b/SharpChat/SockChatServer.cs index b9b56dd..c5114e4 100644 --- a/SharpChat/SockChatServer.cs +++ b/SharpChat/SockChatServer.cs @@ -94,8 +94,6 @@ namespace SharpChat { new PardonUserCommand(msz), new PardonAddressCommand(msz), new BanListCommand(msz), - //new SilenceApplyCommand(), - //new SilenceRevokeCommand(), new RemoteAddressCommand(), });