2023-02-16 20:34:59 +00:00
|
|
|
|
using SharpChat.Packet;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat.Commands {
|
|
|
|
|
public class JoinChannelCommand : IChatCommand {
|
|
|
|
|
public bool IsMatch(ChatCommandContext ctx) {
|
|
|
|
|
return ctx.NameEquals("join");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispatch(ChatCommandContext ctx) {
|
|
|
|
|
string joinChanStr = ctx.Args.FirstOrDefault();
|
|
|
|
|
ChatChannel joinChan;
|
|
|
|
|
lock(ctx.Chat.ChannelsAccess)
|
|
|
|
|
joinChan = ctx.Chat.Channels.FirstOrDefault(c => c.NameEquals(joinChanStr));
|
|
|
|
|
|
|
|
|
|
if(joinChan == null) {
|
2023-02-16 22:33:48 +00:00
|
|
|
|
ctx.Chat.SendTo(ctx.User, new LegacyCommandResponse(LCR.CHANNEL_NOT_FOUND, true, joinChanStr));
|
|
|
|
|
ctx.Chat.ForceChannel(ctx.User);
|
2023-02-16 20:34:59 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ctx.Chat.SwitchChannel(ctx.User, joinChan, string.Join(' ', ctx.Args.Skip(1)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|