using SharpChat.Packet; using System.Linq; namespace SharpChat.Commands { public class AFKCommand : IChatCommand { private const string DEFAULT = "AFK"; private const int MAX_LENGTH = 5; public bool IsMatch(ChatCommandContext ctx) { return ctx.NameEquals("afk"); } public void Dispatch(ChatCommandContext ctx) { string statusText = ctx.Args.FirstOrDefault(); if(string.IsNullOrWhiteSpace(statusText)) statusText = DEFAULT; else { statusText = statusText.Trim(); if(statusText.Length > MAX_LENGTH) statusText = statusText[..MAX_LENGTH].Trim(); } ctx.Chat.UpdateUser( ctx.User, status: ChatUserStatus.Away, statusText: statusText ); } } }