Skip to content

SkyChat Plugin Hooks Documentation

Benjamin Raymond edited this page Nov 26, 2023 · 1 revision

SkyChat Plugin Hooks Documentation

Overview

SkyChat plugins can interact with various events in the messaging application through hooks. These hooks allow plugins to respond to or modify the behavior of specific actions within the application. This document lists all available hooks for RoomPlugin and GlobalPlugin.

Hooks for RoomPlugin

RoomPlugin hooks are specific to room-related events, allowing the plugin to interact with activities within a particular chat room.

onBeforeMessageBroadcastHook(message: Message, connection: Connection): Promise<Message>

  • Description: Executed before a message is broadcasted to the room.
  • Parameters:
    • message: The message about to be broadcasted.
    • connection: The connection that sent the message.
  • Returns: Modified or original Message.

onBeforeConnectionJoinedRoom(connection: Connection): Promise<void>

  • Description: Executed before a connection joins a room.
  • Parameters:
    • connection: The connection attempting to join the room.
  • Returns: Void.

onConnectionJoinedRoom(connection: Connection): Promise<void>

  • Description: Executed when a connection successfully joins a room.
  • Parameters:
    • connection: The connection that joined the room.
  • Returns: Void.

onConnectionLeftRoom(connection: Connection): Promise<void>

  • Description: Executed when a connection leaves a room.
  • Parameters:
    • connection: The connection that left the room.
  • Returns: Void.

Hooks for GlobalPlugin

GlobalPlugin hooks are designed to handle application-wide events and are not specific to any particular room.

onNewMessageHook(message: string, connection: Connection): Promise<string>

  • Description: Executed when a new message is received in the application.
  • Parameters:
    • message: The received message.
    • connection: The connection that sent the message.
  • Returns: Modified or original message string.

onNewConnection(connection: Connection): Promise<void>

  • Description: Executed when a new connection is created.
  • Parameters:
    • connection: The new connection.
  • Returns: Void.

onConnectionAuthenticated(connection: Connection): Promise<void>

  • Description: Executed when a connection successfully authenticates.
  • Parameters:
    • connection: The authenticated connection.
  • Returns: Void.

onConnectionClosed(connection: Connection): Promise<void>

  • Description: Executed when a connection is closed.
  • Parameters:
    • connection: The connection that was closed.
  • Returns: Void.

Conclusion

These hooks provide a powerful interface for RoomPlugin and GlobalPlugin to interact with various events within SkyChat. By utilizing these hooks, developers can create plugins that effectively respond to and influence the behavior of the application, enhancing the user experience in SkyChat.