Reintroduces separate contexts for users, channels, connections (now split into sessions and connections) and user-channel associations. It builds which is as much assurance as I can give about the stability of this commit, but its also the bare minimum of what i like to commit sooooo A lot of things still need to be broadcast through events throughout the application in order to keep states consistent but we'll cross that bridge when we get to it. I really need to stop using that phrase thingy, I'm overusing it.
26 lines
787 B
C#
26 lines
787 B
C#
using SharpChat.Users;
|
|
using System.Globalization;
|
|
using System.Text;
|
|
|
|
namespace SharpChat.ClientCommands;
|
|
|
|
public class AFKClientCommand : ClientCommand {
|
|
private const string DEFAULT = "AFK";
|
|
public const int MAX_GRAPHEMES = 5;
|
|
public const int MAX_BYTES = MAX_GRAPHEMES * 10;
|
|
|
|
public bool IsMatch(ClientCommandContext ctx) {
|
|
return ctx.NameEquals("afk");
|
|
}
|
|
|
|
public async Task Dispatch(ClientCommandContext ctx) {
|
|
string? statusText = ctx.Args.FirstOrDefault();
|
|
statusText = string.IsNullOrWhiteSpace(statusText) ? DEFAULT : statusText.TruncateIfTooLong(MAX_GRAPHEMES, MAX_BYTES).Trim();
|
|
|
|
await ctx.Chat.UpdateUser(
|
|
ctx.User,
|
|
status: UserStatus.Away,
|
|
statusText: statusText
|
|
);
|
|
}
|
|
}
|