Table of Contents

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

IReadOnlyCollection<ICommand>

ReplacementStrings

IReadOnlyCollection<string> ReplacementStrings { get; }

Property Value

IReadOnlyCollection<string>

Methods

CreateCommand(string)

Starts a command built in code. Build on the result registers it.

ICommandDirector CreateCommand(string name)

Parameters

name string

Returns

ICommandDirector

CreateCommandGroup(string)

Starts a command group built in code. Build on the result registers it.

ICommandGroupDirector CreateCommandGroup(string name)

Parameters

name string

Returns

ICommandGroupDirector

DescribeCommands()

Every registered command, groups with the commands under them, as a game shows or completes them.

IReadOnlyList<CommandDescription> DescribeCommands()

Returns

IReadOnlyList<CommandDescription>

Handle(T, string)

Handles a line the source sent.

void Handle(T source, string message)

Parameters

source T
message string

HasCommandCharacter(string)

Returns whether message starts with the command character.

bool HasCommandCharacter(string message)

Parameters

message string

Returns

bool

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

command ICommand

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

replacementText string
action Func<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

source T
message string

Returns

bool

Events

CommandExecuted

Raised after a command runs successfully.

event EventHandler<CommandExecutedEventArgs<T>> CommandExecuted

Event Type

EventHandler<CommandExecutedEventArgs<T>>

CommandNotFound

Raised when a message starts with the command character but names no registered command.

event EventHandler<CommandEventArgs<T>> CommandNotFound

Event Type

EventHandler<CommandEventArgs<T>>

MissingParameterOnCommand

Raised once for each required parameter a command was given no value for.

event EventHandler<MissingParameterEventArgs<T>> MissingParameterOnCommand

Event Type

EventHandler<MissingParameterEventArgs<T>>

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

Event Type

EventHandler<WrongParameterEventArgs<T>>