Fabric API

Fabric API

106M Downloads

Discussion: Chat Event

zml2008 opened this issue ยท 4 comments

commented

Following up from a discussion this evening about chat events, I'd like to write up what I do with chat in my chat plugin, featherchat to help guide development of requirements. These steps are roughly in their current order of operation.

  • Chat filter receive plain chat string, check if it contains any forbidden content that the player does not have permission to override, and cancel the message. A notification is sent to the original sender.
  • Formatting if the chatter has permission to send formatted messages, parse the original chat message as Text XML, returning a Text instance.
  • Layout Process a template, with message and player name among the parameters, returning a text XML string that gets parsed into a Text. This template, by default evaluates to <{{ name }}> {{ message }}, but can be customized by the user.
  • Channels Take the final, formatted messages from both chat and /me, and choose the receivers based on an active chat channel. The channel may apply additional styling to the message.
    FeatherChat supports several types of channels by default: global, to people with a permission, to a defined list of members, and to people within a certain distance of the sender.

I'd appreciate feedback from anyone else who has projects that interact with chat!
/cc @CoolMineman @i509VCB

commented

@apple502j just saw this, does #2220 cover this stuff?

commented

@Technici4n Partially:

  • "Chat filter" should be done using 1.16.4+ text-filtering-config. Exposing this is currently not done but I might add in future versions.
  • "Formatting" is the upcoming message decorator API.
  • "Layout" is the message type dynamic registry in vanilla.
  • "Channel" is not done, but should not be hard.
commented

Some sort of implementation like channels where you can specify who a message should be sent to would be awesome

commented

This should be supported to a sufficient extent by the message API.