28 lines
898 B
C#
28 lines
898 B
C#
using SharpChat.Events;
|
|
using SharpChat.PacketsS2C;
|
|
using System;
|
|
|
|
namespace SharpChat.Commands {
|
|
public class MessageBroadcastCommand : ISockChatClientCommand {
|
|
public bool IsMatch(SockChatClientCommandContext ctx) {
|
|
return ctx.NameEquals("say")
|
|
|| ctx.NameEquals("broadcast");
|
|
}
|
|
|
|
public void Dispatch(SockChatClientCommandContext ctx) {
|
|
if(!ctx.User.Permissions.HasFlag(UserPermissions.Broadcast)) {
|
|
ctx.Chat.SendTo(ctx.User, new CommandNotAllowedErrorS2CPacket(ctx.Name));
|
|
return;
|
|
}
|
|
|
|
ctx.Chat.DispatchEvent(new MessageCreateEvent(
|
|
SharpId.Next(),
|
|
string.Empty,
|
|
ctx.User,
|
|
DateTimeOffset.Now,
|
|
string.Join(' ', ctx.Args),
|
|
false, false, true
|
|
));
|
|
}
|
|
}
|
|
}
|