Interface IChatEngine<T>
- Namespace
- BSGameLib.Chat
- Assembly
- BSGameLib.Chat.dll
A chat engine for messages from sources of type T.
public interface IChatEngine<T> where T : IMessageSource
Type Parameters
T
Properties
Commands
The registered commands and command groups, at the top level.
IReadOnlyCollection<ICommand> Commands { get; }
Property Value
ReplacementStrings
The tokens registered with RegisterStringReplacement(string, Func<IMessageContext<T>, string>).
IReadOnlyCollection<string> ReplacementStrings { get; }
Property Value
Methods
CreateCommand(string)
Starts a command built in code. Build on the result registers it.
ICommandDirector CreateCommand(string name)
Parameters
namestring
Returns
CreateCommandGroup(string)
Starts a command group built in code. Build on the result registers it.
ICommandGroupDirector CreateCommandGroup(string name)
Parameters
namestring
Returns
DescribeCommands()
Every registered command, groups with the commands under them, as a game shows or completes them.
IReadOnlyList<CommandDescription> DescribeCommands()
Returns
Handle(T, string)
Handles a line the source sent.
void Handle(T source, string message)
Parameters
sourceTmessagestring
HasCommandCharacter(string)
Returns whether message starts with the command character.
bool HasCommandCharacter(string message)
Parameters
messagestring
Returns
Initialize()
Registers the commands of the engine's ICommandProviders. A server calls it before it listens, and a game may call it too, so it must be safe to call more than once: an override that does work of its own does it on the first call only, as the base does.
void Initialize()
RegisterCommand(ICommand)
Registers a command. See RegisterCommand(ICommand).
void RegisterCommand(ICommand command)
Parameters
commandICommand
RegisterCommand<TCommand>()
Registers the command type TCommand from its attributes.
void RegisterCommand<TCommand>() where TCommand : ICommand
Type Parameters
TCommand
RegisterStringReplacement(string, Func<IMessageContext<T>, string>)
Registers a token that is replaced in messages before they are handled.
void RegisterStringReplacement(string replacementText, Func<IMessageContext<T>, string> action)
Parameters
replacementTextstringactionFunc<IMessageContext<T>, string>
TryHandleCommand(T, ref string)
Runs message as a command if it starts with the command character, after
filling in replacement tokens. message is updated to the filled-in text.
Returns false when the message is chat.
bool TryHandleCommand(T source, ref string message)
Parameters
sourceTmessagestring
Returns
Events
CommandExecuted
Raised after a command runs successfully.
event EventHandler<CommandExecutedEventArgs<T>> CommandExecuted
Event Type
CommandNotFound
Raised when a message starts with the command character but names no registered command.
event EventHandler<CommandEventArgs<T>> CommandNotFound
Event Type
MissingParameterOnCommand
Raised once for each required parameter a command was given no value for.
event EventHandler<MissingParameterEventArgs<T>> MissingParameterOnCommand
Event Type
WrongParameterOnCommand
A command was given a value one of its parameters cannot take -- a word where a number goes -- and did not run.
event EventHandler<WrongParameterEventArgs<T>> WrongParameterOnCommand