2023-07-23 21:31:13 +00:00
|
|
|
|
using SharpChat.Events;
|
2023-02-16 20:34:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
2024-05-20 23:40:34 +00:00
|
|
|
|
namespace SharpChat.SockChat.Commands {
|
2024-05-20 23:00:47 +00:00
|
|
|
|
public class MessageActionCommand : ISockChatClientCommand {
|
|
|
|
|
public bool IsMatch(SockChatClientCommandContext ctx) {
|
2023-02-16 20:34:59 +00:00
|
|
|
|
return ctx.NameEquals("action")
|
|
|
|
|
|| ctx.NameEquals("me");
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-20 23:00:47 +00:00
|
|
|
|
public void Dispatch(SockChatClientCommandContext 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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|