30 lines
824 B
C#
30 lines
824 B
C#
using SharpChat.Events;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace SharpChat.Commands {
|
|
public class MessageActionCommand : IUserCommand {
|
|
public bool IsMatch(UserCommandContext ctx) {
|
|
return ctx.NameEquals("action")
|
|
|| ctx.NameEquals("me");
|
|
}
|
|
|
|
public void Dispatch(UserCommandContext ctx) {
|
|
if(!ctx.Args.Any())
|
|
return;
|
|
|
|
string actionStr = string.Join(' ', ctx.Args);
|
|
if(string.IsNullOrWhiteSpace(actionStr))
|
|
return;
|
|
|
|
ctx.Chat.DispatchEvent(new MessageCreateEvent(
|
|
SharpId.Next(),
|
|
ctx.Channel,
|
|
ctx.User,
|
|
DateTimeOffset.Now,
|
|
actionStr,
|
|
false, true, false
|
|
));
|
|
}
|
|
}
|
|
}
|