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 {
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public class MessageActionCommand : IUserCommand {
|
|
|
|
|
public bool IsMatch(UserCommandContext ctx) {
|
2023-02-16 20:34:59 +00:00
|
|
|
|
return ctx.NameEquals("action")
|
|
|
|
|
|| ctx.NameEquals("me");
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-19 02:17:51 +00:00
|
|
|
|
public void Dispatch(UserCommandContext 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|