diff --git a/package.json b/package.json index f8180c4f..224358a2 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.27.1", + "version": "4.28.0", "description": "FrankerFaceZ is a Twitch enhancement suite.", "private": true, "license": "Apache-2.0", diff --git a/src/main.js b/src/main.js index 4277e3b3..f48f3db7 100644 --- a/src/main.js +++ b/src/main.js @@ -185,6 +185,7 @@ FrankerFaceZ.utilities = { tooltip: require('utilities/tooltip'), i18n: require('utilities/translation-core'), dayjs: require('dayjs'), + filtering: require('utilities/filtering'), popper: require('popper.js').default } diff --git a/src/modules/chat/badges.jsx b/src/modules/chat/badges.jsx index b648234a..f82b0765 100644 --- a/src/modules/chat/badges.jsx +++ b/src/modules/chat/badges.jsx @@ -424,24 +424,29 @@ export default class Badges extends Module { if ( target.dataset.badgeData ) data = JSON.parse(target.dataset.badgeData); else { - const badge_idx = target.dataset.badgeIdx, - fine = this.resolve('site.fine'); + const badge_idx = target.dataset.badgeIdx; + let message; - if ( fine ) { - let message; - message = container[fine.accessor]?.return?.stateNode?.props?.message; - if ( ! message ) - 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 ( container.message ) + message = container.message; + else { + const fine = this.resolve('site.fine'); - if ( message?._ffz_message) - message = message._ffz_message; - if ( message ) - data = message.ffz_badge_cache?.[badge_idx]?.[1]?.badges; + if ( fine ) { + message = container[fine.accessor]?.return?.stateNode?.props?.message; + if ( ! message ) + 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 ) diff --git a/src/sites/twitch-twilight/modules/chat/index.js b/src/sites/twitch-twilight/modules/chat/index.js index 61eccb1d..19317949 100644 --- a/src/sites/twitch-twilight/modules/chat/index.js +++ b/src/sites/twitch-twilight/modules/chat/index.js @@ -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', { default: true, ui: { @@ -1518,7 +1528,13 @@ export default class ChatHook extends Module { 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) ) { //t.log.info('Moderation Action', msg); if ( ! inst.props.isCurrentUserModerator ) @@ -1613,12 +1629,14 @@ export default class ChatHook extends Module { return; - } else if ( msg.type === types.Clear ) { + } */ else if ( msg.type === types.Clear ) { if ( t.chat.context.get('chat.filtering.ignore-clear') ) msg = { type: types.Info, 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) { diff --git a/src/sites/twitch-twilight/modules/chat/line.js b/src/sites/twitch-twilight/modules/chat/line.js index 55b5ecf4..e206b5d2 100644 --- a/src/sites/twitch-twilight/modules/chat/line.js +++ b/src/sites/twitch-twilight/modules/chat/line.js @@ -844,6 +844,25 @@ other {# messages were deleted by a moderator.} 'data-user': user.userLogin && user.userLogin.toLowerCase() }, 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 ) diff --git a/src/utilities/constants.js b/src/utilities/constants.js index d8c1534d..06ad3bc0 100644 --- a/src/utilities/constants.js +++ b/src/utilities/constants.js @@ -43,7 +43,8 @@ export const RERENDER_SETTINGS = [ 'chat.points.allow-highlight', 'chat.filtering.display-deleted', 'chat.filtering.display-mod-action', - 'chat.replies.style' + 'chat.replies.style', + 'chat.bits.cheer-notice' ]; export const UPDATE_BADGE_SETTINGS = [