2023-07-23 21:31:13 +00:00
|
|
|
|
using SharpChat.Events;
|
2023-02-16 20:34:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2023-07-23 21:31:13 +00:00
|
|
|
|
namespace SharpChat.Commands {
|
2023-02-16 20:34:59 +00:00
|
|
|
|
public class ActionCommand : IChatCommand {
|
|
|
|
|
public bool IsMatch(ChatCommandContext ctx) {
|
|
|
|
|
return ctx.NameEquals("action")
|
|
|
|
|
|| ctx.NameEquals("me");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispatch(ChatCommandContext ctx) {
|
2023-07-23 21:31:13 +00:00
|
|
|
|
if(!ctx.Args.Any())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string actionStr = string.Join(' ', ctx.Args);
|
|
|
|
|
if(string.IsNullOrWhiteSpace(actionStr))
|
|
|
|
|
return;
|
2023-02-16 20:34:59 +00:00
|
|
|
|
|
2023-07-23 21:31:13 +00:00
|
|
|
|
ctx.Chat.DispatchEvent(new MessageCreateEvent(
|
|
|
|
|
SharpId.Next(),
|
|
|
|
|
ctx.Channel,
|
|
|
|
|
ctx.User,
|
|
|
|
|
DateTimeOffset.Now,
|
|
|
|
|
actionStr,
|
|
|
|
|
false, true, false
|
|
|
|
|
));
|
2023-02-16 20:34:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|