Table of Contents

Interface IPluginChat

Namespace
AcDream.Plugin.Abstractions
Assembly
AcDream.Plugin.Abstractions.dll

Reading the client's text, printing into it, dropping lines before they are shown, and intercepting lines before they are sent.

public interface IPluginChat

Fields

MaximumInputInterceptors

The most input interceptors one plugin may have installed at once. A registration past this is refused with an exception rather than silently ignored, so a plugin finds out.

public const int MaximumInputInterceptors = 16

Field Value

int

Properties

IsInputActive

True while the player is typing into the chat entry, so the keyboard is going into text rather than driving the character. Automation that steers by holding keys has to fall back to something else while this is set. A host with no chat entry answers false.

bool IsInputActive { get; }

Property Value

bool

Methods

CaptureMessages(ulong)

Every retained line whose Sequence is above the one given. The host keeps only the most recent few hundred lines, so a plugin that polls rarely loses the overflow; subscribe to Received when nothing may be missed. Empty when there is nothing newer, and on a host that retains no lines.

IReadOnlyList<PluginChatMessage> CaptureMessages(ulong afterSequence)

Parameters

afterSequence ulong

Returns

IReadOnlyList<PluginChatMessage>

Compose(string)

Puts text into the chat entry and focuses it, WITHOUT sending it, so the player can finish typing. False when there is no chat entry to type into or the player is already typing in it.

bool Compose(string text)

Parameters

text string

Returns

bool

PostMessage(string, int)

Writes a line in one of the client's own text classes, so a plugin can print in the colour that class carries.

void PostMessage(string text, int logTextType)

Parameters

text string
logTextType int

PostSystemMessage(string)

Writes a line into the client's own text, visible only to this player. Nothing is sent to the server.

void PostSystemMessage(string text)

Parameters

text string

RegisterFilter(Func<PluginChatMessage, bool>)

Installs a filter consulted before a line is shown. Returning true drops the line: it never reaches the transcript, the chat windows, CaptureMessages(ulong), Received, or the log file. Filters run in registration order, and one that throws suppresses nothing. Dispose the result to remove it; the host also removes every filter a plugin installed when that plugin unloads. A filter sees the line before the language filter censors it; readers see it censored.

IDisposable RegisterFilter(Func<PluginChatMessage, bool> suppress)

Parameters

suppress Func<PluginChatMessage, bool>

Returns

IDisposable

RegisterInputInterceptor(Func<string, PluginChatInputDecision>)

Installs an interceptor consulted for every line the player sends from the chat entry, on either front end, and for every line a plugin sends through Submit(string). The interceptor sees the line trimmed, otherwise exactly as typed, and answers with a PluginChatInputDecision.

Ordering: interceptors run AFTER the client's own command catalogue, so a line the client claims as one of its own commands never reaches an interceptor and no plugin can shadow or rewrite a client command. They run BEFORE plugin verbs and before the line is dispatched to a channel or a tell, so a rewritten line can itself become a plugin verb or a channel message. Interceptors run in registration order across every plugin, and the first one that does not pass decides.

A rewrite is fed back through the pipeline from the start, so it may be intercepted again. The host bounds the rewrite passes; once the bound is reached the last text is sent as it stands. A suppressed line is sent nowhere and runs no command; the player is told nothing unless the plugin posts something. An interceptor that throws is logged once and skipped for that line, and chat carries on without it.

Dispose the result to remove the interceptor; the host also removes every interceptor a plugin installed when that plugin unloads. A host that has no chat pipeline to intercept returns a handle that revokes nothing and never calls the interceptor, which is what the default implementation does.

IDisposable RegisterInputInterceptor(Func<string, PluginChatInputDecision> intercept)

Parameters

intercept Func<string, PluginChatInputDecision>

Given the typed line, answers what to do with it.

Returns

IDisposable

A handle that removes the interceptor when disposed.

Exceptions

InvalidOperationException

The plugin already has MaximumInputInterceptors installed.

Submit(string)

Runs text through the client's chat bar exactly as if the player had typed and sent it, commands included. Returns false when the text is blank or the host has no chat bar to submit to.

bool Submit(string text)

Parameters

text string

Returns

bool

Events

LinkClicked

Raised for every line the client takes delivery of, in order, on the thread that raises Tick. Unlike CaptureMessages(ulong), nothing is dropped between polls.

event Action<PluginChatLinkClicked> LinkClicked

Event Type

Action<PluginChatLinkClicked>

Received

Raised for each delivered chat line.

event Action<PluginChatMessage> Received

Event Type

Action<PluginChatMessage>