sharp-chat/SharpChat.Protocol.IRC/ClientCommands/PassCommand.cs

27 lines
810 B
C#
Raw Permalink Normal View History

2022-08-30 15:05:29 +00:00
using SharpChat.Protocol.IRC.Replies;
using System.Linq;
namespace SharpChat.Protocol.IRC.ClientCommands {
public class PassCommand : IClientCommand {
public const string NAME = @"PASS";
public string CommandName => NAME;
public bool RequireSession => false;
public void HandleCommand(ClientCommandContext ctx) {
if(ctx.Connection.HasAuthenticated) {
ctx.Connection.SendReply(new AlreadyRegisteredReply());
return;
}
string password = ctx.Arguments.FirstOrDefault();
if(string.IsNullOrWhiteSpace(password)) {
ctx.Connection.SendReply(new NeedMoreParamsReply(NAME));
return;
}
ctx.Connection.Password = password;
}
}
}