sharp-chat/SharpChat.Protocol.SockChat/Commands/LeaveCommand.cs

32 lines
989 B
C#
Raw Permalink Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Protocol.SockChat.Packets;
using SharpChat.Users;
using System;
using System.Collections.Generic;
namespace SharpChat.Protocol.SockChat.Commands {
public class LeaveCommand : ICommand {
public const string NAME = @"leave";
public bool IsCommandMatch(string name, IEnumerable<string> args)
=> name == NAME;
private IUser Sender { get; }
public LeaveCommand(IUser sender) {
Sender = sender ?? throw new ArgumentNullException(nameof(sender));
}
public bool DispatchCommand(CommandContext ctx) {
if(!ctx.Connection.HasCapability(ClientCapability.MCHAN)) {
ctx.Connection.SendPacket(new CommandNotFoundErrorPacket(Sender, NAME));
return true;
}
// figure out the channel leaving logic
// should i postpone this implementation till i have the event based shit in place?
return true;
}
}
}