1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-28 15:27:43 +00:00
* Added: Setting to display a system message on chat messages that contain bits, enabled by default.
* API Added: Expose `filtering` utilities.
* API Added: Events `chat:mod-user` and `chat:clear-chat`.
This commit is contained in:
SirStendec 2021-07-12 13:46:04 -04:00
parent 3b4ecfaa23
commit 0c25692afd
6 changed files with 63 additions and 19 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "frankerfacez", "name": "frankerfacez",
"author": "Dan Salvato LLC", "author": "Dan Salvato LLC",
"version": "4.27.1", "version": "4.28.0",
"description": "FrankerFaceZ is a Twitch enhancement suite.", "description": "FrankerFaceZ is a Twitch enhancement suite.",
"private": true, "private": true,
"license": "Apache-2.0", "license": "Apache-2.0",

View file

@ -185,6 +185,7 @@ FrankerFaceZ.utilities = {
tooltip: require('utilities/tooltip'), tooltip: require('utilities/tooltip'),
i18n: require('utilities/translation-core'), i18n: require('utilities/translation-core'),
dayjs: require('dayjs'), dayjs: require('dayjs'),
filtering: require('utilities/filtering'),
popper: require('popper.js').default popper: require('popper.js').default
} }

View file

@ -424,24 +424,29 @@ export default class Badges extends Module {
if ( target.dataset.badgeData ) if ( target.dataset.badgeData )
data = JSON.parse(target.dataset.badgeData); data = JSON.parse(target.dataset.badgeData);
else { else {
const badge_idx = target.dataset.badgeIdx, const badge_idx = target.dataset.badgeIdx;
fine = this.resolve('site.fine'); let message;
if ( fine ) { if ( container.message )
let message; message = container.message;
message = container[fine.accessor]?.return?.stateNode?.props?.message; else {
if ( ! message ) const fine = this.resolve('site.fine');
message = fine.searchParent(container, n => n.props?.message)?.props?.message;
if ( ! message )
message = fine.searchParent(container, n => n.props?.node)?.props?.node?._ffz_message;
if ( ! message )
message = fine.searchParent(container, n => n.props?.messageContext)?.props?.messageContext?.comment?._ffz_message;
if ( message?._ffz_message) if ( fine ) {
message = message._ffz_message; message = container[fine.accessor]?.return?.stateNode?.props?.message;
if ( message ) if ( ! message )
data = message.ffz_badge_cache?.[badge_idx]?.[1]?.badges; message = fine.searchParent(container, n => n.props?.message)?.props?.message;
if ( ! message )
message = fine.searchParent(container, n => n.props?.node)?.props?.node?._ffz_message;
if ( ! message )
message = fine.searchParent(container, n => n.props?.messageContext)?.props?.messageContext?.comment?._ffz_message;
}
} }
if ( message?._ffz_message)
message = message._ffz_message;
if ( message )
data = message.ffz_badge_cache?.[badge_idx]?.[1]?.badges;
} }
if ( data == null ) if ( data == null )

View file

@ -511,6 +511,16 @@ export default class ChatHook extends Module {
} }
}); });
this.settings.add('chat.bits.cheer-notice', {
default: true,
ui: {
path: 'Chat > Bits and Cheering >> Appearance',
title: 'Display a notice on chat messages that include cheers.',
description: 'This feature is intended to prevent possible confusion from chatters using emotes to fake cheers in messages. When enabled, messages that contain real cheers will display a message above them, similar to how resubscription messages or point redemptions with messages function.',
component: 'setting-check-box'
}
});
this.settings.add('chat.rituals.show', { this.settings.add('chat.rituals.show', {
default: true, default: true,
ui: { ui: {
@ -1518,7 +1528,13 @@ export default class ChatHook extends Module {
return; return;
} }
} else if ( msg.type === types.ModerationAction && false && inst.markUserEventDeleted && inst.unsetModeratedUser ) { } /*else if ( msg.type === types.ModerationAction ) {
t.emit('chat:mod-user', msg.moderationActionType, )
} */ else if ( msg.type === types.Moderation ) {
t.emit('chat:mod-user', msg.moderationType, msg.userLogin, msg.targetMessageID, msg);
} /*else if ( msg.type === types.ModerationAction && false && inst.markUserEventDeleted && inst.unsetModeratedUser ) {
if ( !((! msg.level || ! msg.level.length) && msg.targetUserLogin && msg.targetUserLogin === inst.props.currentUserLogin) ) { if ( !((! msg.level || ! msg.level.length) && msg.targetUserLogin && msg.targetUserLogin === inst.props.currentUserLogin) ) {
//t.log.info('Moderation Action', msg); //t.log.info('Moderation Action', msg);
if ( ! inst.props.isCurrentUserModerator ) if ( ! inst.props.isCurrentUserModerator )
@ -1613,12 +1629,14 @@ export default class ChatHook extends Module {
return; return;
} else if ( msg.type === types.Clear ) { } */ else if ( msg.type === types.Clear ) {
if ( t.chat.context.get('chat.filtering.ignore-clear') ) if ( t.chat.context.get('chat.filtering.ignore-clear') )
msg = { msg = {
type: types.Info, type: types.Info,
message: t.i18n.t('chat.ignore-clear', 'An attempt by a moderator to clear chat was ignored.') message: t.i18n.t('chat.ignore-clear', 'An attempt by a moderator to clear chat was ignored.')
} }
else
t.emit('chat:clear-chat', msg);
} }
} catch(err) { } catch(err) {

View file

@ -844,6 +844,25 @@ other {# messages were deleted by a moderator.}
'data-user': user.userLogin && user.userLogin.toLowerCase() 'data-user': user.userLogin && user.userLogin.toLowerCase()
}, out) }, out)
] ]
} else if ( msg.bits > 0 && t.chat.context.get('chat.bits.cheer-notice') ) {
cls = `ffz-notice-line user-notice-line tw-pd-y-05 tw-pd-r-2 ffz--ritual-line${show_class ? ' ffz--deleted-message' : ''}${twitch_clickable ? ' tw-relative' : ''}`;
out = [
e('div', {className: 'tw-c-text-alt-2'}, [
out ? null : extra_ts && (this.props.showTimestamps || this.props.isHistorical) && e('span', {
className: 'chat-line__timestamp'
}, t.chat.formatTime(msg.timestamp)),
out ? null : t.actions.renderInline(msg, this.props.showModerationIcons, u, r, e),
t.i18n.tList('chat.bits-message', 'Cheered {count, plural, one {# Bit} other {# Bits}}', {count: msg.bits || 0})
]),
out && e('div', {
className: 'chat-line--inline chat-line__message',
'data-room-id': room_id,
'data-room': room,
'data-user-id': user.userID,
'data-user': user.userLogin && user.userLogin.toLowerCase(),
}, out)
];
} }
if ( ! out ) if ( ! out )

View file

@ -43,7 +43,8 @@ export const RERENDER_SETTINGS = [
'chat.points.allow-highlight', 'chat.points.allow-highlight',
'chat.filtering.display-deleted', 'chat.filtering.display-deleted',
'chat.filtering.display-mod-action', 'chat.filtering.display-mod-action',
'chat.replies.style' 'chat.replies.style',
'chat.bits.cheer-notice'
]; ];
export const UPDATE_BADGE_SETTINGS = [ export const UPDATE_BADGE_SETTINGS = [