Removed any remaining references to silencing.

This commit is contained in:
Pachira 2023-07-23 21:36:22 +00:00
parent 8c19c22736
commit 903e39ab76
8 changed files with 2 additions and 191 deletions

View file

@ -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.

View file

@ -5,7 +5,7 @@ namespace SharpChat {
public enum ChatUserPermissions : int {
KickUser = 0x00000001,
BanUser = 0x00000002,
SilenceUser = 0x00000004,
//SilenceUser = 0x00000004,
Broadcast = 0x00000008,
SetOwnNickname = 0x00000010,
SetOthersNickname = 0x00000020,

View file

@ -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));
}
}
}

View file

@ -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));
}
}
}

View file

@ -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; }
}

View file

@ -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";

View file

@ -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)

View file

@ -94,8 +94,6 @@ namespace SharpChat {
new PardonUserCommand(msz),
new PardonAddressCommand(msz),
new BanListCommand(msz),
//new SilenceApplyCommand(),
//new SilenceRevokeCommand(),
new RemoteAddressCommand(),
});