1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-31 23:18:31 +00:00

4.0.0-rc17

* Added: Highlight messages based on usernames and badges.
* Added: Block messages based on usernames and badges.

* Fixed: Display the number of months a subscriber has subscribed in badge tool-tips.
* Fixed: Rendering of chat messages sent from Twitch Extensions.
This commit is contained in:
SirStendec 2019-04-28 17:28:16 -04:00
parent b9cca1053d
commit 1649294bde
10 changed files with 809 additions and 82 deletions

View file

@ -186,6 +186,7 @@ export default class Chat extends Module {
ui: {
path: 'Chat > Behavior >> Deleted Messages',
title: 'Deleted Message Style',
description: 'This style will be applied to deleted messages showed in Detailed rendering mode to differentiate them from normal chat messages.',
component: 'setting-select-box',
data: [
{value: 0, title: 'Faded'},
@ -200,8 +201,8 @@ export default class Chat extends Module {
default: false,
ui: {
path: 'Chat > Behavior >> Deleted Messages',
title: 'Deleted Message Rendering',
description: 'This, when set, overrides the mode selected in Twitch Chat settings. We do this to allow non-moderators access to the setting.',
title: 'Rendering Mode',
description: 'This, when set, overrides the mode selected in Twitch chat settings. We do this to allow non-moderators access to the setting.',
component: 'setting-select-box',
data: [
{value: false, title: 'Do Not Override'},
@ -216,7 +217,7 @@ export default class Chat extends Module {
default: 1,
ui: {
path: 'Chat > Behavior >> Deleted Messages',
title: 'Display Deletion Reason',
title: 'Display Reason',
component: 'setting-select-box',
data: [
{value: 0, title: 'Never'},
@ -285,6 +286,177 @@ export default class Chat extends Module {
}
});
this.settings.add('chat.filtering.highlight-basic-users', {
default: [],
type: 'array_merge',
always_inherit: true,
ui: {
path: 'Chat > Filtering >> Highlight Users',
component: 'basic-terms',
colored: true,
words: false
}
});
this.settings.add('chat.filtering.highlight-basic-users--color-regex', {
requires: ['chat.filtering.highlight-basic-users'],
process(ctx) {
const val = ctx.get('chat.filtering.highlight-basic-users');
if ( ! val || ! val.length )
return null;
const colors = new Map;
for(const item of val) {
const c = item.c || null,
t = item.t;
let v = item.v;
if ( t === 'glob' )
v = glob_to_regex(v);
else if ( t !== 'raw' )
v = escape_regex(v);
if ( ! v || ! v.length )
continue;
try {
new RegExp(v);
} catch(err) {
continue;
}
if ( colors.has(c) )
colors.get(c).push(v);
else {
colors.set(c, [v]);
}
}
for(const [key, list] of colors) {
colors.set(key, new RegExp(`^${list.join('|')}$`, 'gi'));
}
return colors;
}
});
this.settings.add('chat.filtering.highlight-basic-users-blocked', {
default: [],
type: 'array_merge',
always_inherit: true,
ui: {
path: 'Chat > Filtering >> Blocked Users',
component: 'basic-terms',
removable: true,
words: false
}
});
this.settings.add('chat.filtering.highlight-basic-users-blocked--regex', {
requires: ['chat.filtering.highlight-basic-blocked'],
process(ctx) {
const val = ctx.get('chat.filtering.highlight-basic-users-blocked');
if ( ! val || ! val.length )
return null;
const out = [[], []];
for(const item of val) {
const t = item.t;
let v = item.v;
if ( t === 'glob' )
v = glob_to_regex(v);
else if ( t !== 'raw' )
v = escape_regex(v);
if ( ! v || ! v.length )
continue;
out[item.remove ? 1 : 0].push(v);
}
return out.map(data => {
if ( ! data.length )
return null;
return new RegExp(`^${data.join('|')}$`, 'gi');
});
}
});
this.settings.add('chat.filtering.highlight-basic-badges', {
default: [],
type: 'array_merge',
always_inherit: true,
ui: {
path: 'Chat > Filtering >> Highlight Badges',
component: 'badge-highlighting',
colored: true,
data: () => this.badges.getSettingsBadges()
}
});
this.settings.add('chat.filtering.highlight-basic-badges--colors', {
requires: ['chat.filtering.highlight-basic-badges'],
process(ctx) {
const val = ctx.get('chat.filtering.highlight-basic-badges');
if ( ! val || ! val.length )
return null;
const colors = new Map;
for(const item of val) {
const c = item.c || null,
v = item.v;
colors.set(v, c);
}
return colors;
}
});
this.settings.add('chat.filtering.highlight-basic-badges-blocked', {
default: [],
type: 'array_merge',
always_inherit: true,
ui: {
path: 'Chat > Filtering >> Blocked Badges',
component: 'badge-highlighting',
removable: true,
data: () => this.badges.getSettingsBadges()
}
});
this.settings.add('chat.filtering.highlight-basic-badges-blocked--list', {
requires: ['chat.filtering.highlight-basic-badges-blocked'],
process(ctx) {
const val = ctx.get('chat.filtering.highlight-basic-badges-blocked');
if ( ! val || ! val.length )
return null;
const out = [[], []];
for(const item of val)
if ( item.v )
out[item.remove ? 1 : 0].push(item.v);
if ( ! out[0].length && ! out[1].length )
return null;
return out;
}
});
this.settings.add('chat.filtering.highlight-basic-terms', {
default: [],
@ -297,7 +469,6 @@ export default class Chat extends Module {
}
});
this.settings.add('chat.filtering.highlight-basic-terms--color-regex', {
requires: ['chat.filtering.highlight-basic-terms'],
process(ctx) {
@ -636,10 +807,10 @@ export default class Chat extends Module {
if ( id && typeof id === 'number' )
id = `${id}`;
if ( this.user_ids[id] )
if ( id && this.user_ids[id] )
user = this.user_ids[id];
else if ( this.users[login] && ! no_login )
else if ( login && this.users[login] && ! no_login )
user = this.users[login];
if ( user && user.destroyed )
@ -696,10 +867,10 @@ export default class Chat extends Module {
if ( id && typeof id === 'number' )
id = `${id}`;
if ( this.room_ids[id] )
if ( id && this.room_ids[id] )
room = this.room_ids[id];
else if ( this.rooms[login] && ! no_login )
else if ( login && this.rooms[login] && ! no_login )
room = this.rooms[login];
if ( room && room.destroyed )
@ -863,7 +1034,9 @@ export default class Chat extends Module {
if ( ! user )
user = msg.user = {};
user.color = user.color || user.chatColor || null;
const ext = msg.extension || {};
user.color = user.color || user.chatColor || ext.chatColor || null;
user.type = user.type || user.userType || null;
user.id = user.id || user.userID || null;
user.login = user.login || user.userLogin || null;
@ -888,7 +1061,13 @@ export default class Chat extends Module {
// Standardize Badges
if ( ! msg.badges && user.displayBadges ) {
const b = msg.badges = {};
for(const item of msg.user.displayBadges)
for(const item of user.displayBadges)
b[item.setID] = item.version;
}
if ( ! msg.badges && ext.displayBadges ) {
const b = msg.badges = {};
for(const item of ext.displayBadges)
b[item.setID] = item.version;
}