2023-07-23 21:31:13 +00:00
|
|
|
|
using SharpChat.Events;
|
|
|
|
|
using SharpChat.Packet;
|
|
|
|
|
using System;
|
2023-02-16 20:34:59 +00:00
|
|
|
|
|
|
|
|
|
namespace SharpChat.Commands {
|
2024-05-14 22:17:25 +00:00
|
|
|
|
public class MessageBroadcastCommand : IChatCommand {
|
2023-02-16 20:34:59 +00:00
|
|
|
|
public bool IsMatch(ChatCommandContext ctx) {
|
|
|
|
|
return ctx.NameEquals("say")
|
|
|
|
|
|| ctx.NameEquals("broadcast");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispatch(ChatCommandContext ctx) {
|
2024-05-17 23:50:22 +00:00
|
|
|
|
if(!ctx.User.Permissions.HasFlag(ChatUserPermissions.Broadcast)) {
|
2024-05-14 19:11:09 +00:00
|
|
|
|
ctx.Chat.SendTo(ctx.User, new CommandNotAllowedErrorPacket(ctx.Name));
|
2023-02-16 20:34:59 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-23 21:31:13 +00:00
|
|
|
|
ctx.Chat.DispatchEvent(new MessageCreateEvent(
|
|
|
|
|
SharpId.Next(),
|
|
|
|
|
string.Empty,
|
|
|
|
|
ctx.User,
|
|
|
|
|
DateTimeOffset.Now,
|
|
|
|
|
string.Join(' ', ctx.Args),
|
|
|
|
|
false, false, true
|
|
|
|
|
));
|
2023-02-16 20:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|