Skip to main content

View as Markdown · AI documentation index

Type Alias: ChatCallbacks

ChatCallbacks = object

Defined in: chat.ts:78

Optional callbacks fired after a chat changes.

Remarks​

Callbacks run after the state change they describe, and a callback that throws is reported without corrupting the transcript. Chat callbacks fire before the ones registered on defineMessenger().

Properties​

onChoice()?​

optional onChoice: (event) => void

Defined in: chat.ts:99

Fires after the player's reply has been logged.

Parameters​

event​
chat​

Chat

choiceId​

string

index​

number

option​

ChoiceOption

Returns​

void


onParticipantChange()?​

optional onParticipantChange: (event) => void

Defined in: chat.ts:113

Fires when a group's membership changes.

Parameters​

event​
added?​

string

chat​

Chat

participants​

string[]

removed?​

string

Returns​

void


onScriptEnd()?​

optional onScriptEnd: (event) => void

Defined in: chat.ts:110

Fires when a script runs out of beats.

Parameters​

event​
chat​

Chat

scriptId​

string

Returns​

void


onSeen()?​

optional onSeen: (event) => void

Defined in: chat.ts:96

Fires when entries transition to seen, with the entries that changed.

Parameters​

event​
chat​

Chat

entries​

TranscriptEntry[]

Returns​

void


onSend()?​

optional onSend: (event) => void

Defined in: chat.ts:93

Fires for every entry appended to the transcript - from a contact, from the player, and for system notices alike.

Parameters​

event​
chat​

Chat

entry​

TranscriptEntry

Returns​

void

Example​

defineChat('anna', {
peer: anna,
onSend: ({ entry }) => {
if (entry.from !== 'player') notificationSound.play();
},
});

onTyping()?​

optional onTyping: (event) => void

Defined in: chat.ts:107

Fires when the set of typing contacts changes.

Parameters​

event​
chat​

Chat

typing​

string[]

Returns​

void