1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-03 03:40:56 +00:00
* API Added: When adding a command to tab-completion with the `chat:get-tab-commands` event, you can now specify a `prefix` for your command. Valid options: `!` and `/`. Defaults to `/` if not specified.
* API Added: New `chat:update-line` event. Signature: `(messageId: string, clearTokens: boolean = true, clearBadges?: boolean)`. To re-render a chatline without re-tokenizing it, pass `false` as the second argument.
* API Changed: Whisper / video chat messages now have their message IDs correctly added to their standardized message objects.
This commit is contained in:
SirStendec 2024-03-16 20:34:27 -04:00
parent 3aeb70f0fb
commit 8807e09ea3
6 changed files with 133 additions and 5 deletions

View file

@ -486,6 +486,7 @@ export default class ChatLine extends Module {
async onEnable() {
this.on('chat.overrides:changed', id => this.updateLinesByUser(id, null, false, false), this);
this.on('chat:update-lines-by-user', this.updateLinesByUser, this);
this.on('chat:update-line', this.updateLineById, this);
this.on('chat:update-lines', this.updateLines, this);
this.on('chat:rerender-lines', this.rerenderLines, this);
this.on('chat:update-line-tokens', this.updateLineTokens, this);
@ -1440,6 +1441,39 @@ other {# messages were deleted by a moderator.}
}
}
updateLineById(id, clear_tokens = true, clear_badges = null) {
if ( clear_badges == null )
clear_badges = clear_tokens;
for(const inst of this.ChatLine.instances) {
const msg = inst.props.message;
if ( msg?.id === id ) {
if ( clear_badges )
msg.ffz_badges = msg.ffz_badge_cache = null;
if ( clear_tokens ) {
msg.ffz_tokens = null;
msg.ffz_reply = null;
msg.highlights = msg.mentioned = msg.mention_color = msg.color_priority = null;
}
inst.forceUpdate();
return;
}
}
for(const inst of this.WhisperLine.instances) {
const msg = inst.props.message?._ffz_message;
if ( msg?.id === id ) {
// TODO: Better support for clear_tokens and clear_badges
if ( clear_badges || clear_tokens )
msg._ffz_message = null;
inst.forceUpdate();
return;
}
}
}
updateLinesByUser(id, login, clear_tokens = true, clear_badges = true) {
for(const inst of this.ChatLine.instances) {