1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 02:16:54 +00:00

4.0.0-rc3. Display a warning for complex or invalid filtering terms, using the safe-regex NPM module. Add a separate Regex (Word) filtering mode. Fix channel hosting control. Fix hide extensions. Add a fix for bad local echo emote indices for chat. Position the color picker above rather than below for filter terms. Apply a dark theme to the color picker. Rewrite the filter terms editor to use the term editor component for adding a new term.

This commit is contained in:
SirStendec 2018-06-27 14:13:59 -04:00
parent 2a790ad7cd
commit 038270d232
23 changed files with 669 additions and 423 deletions

View file

@ -566,6 +566,25 @@ export default class ChatHook extends Module {
}
cls.prototype.ffzGetEmotes = function() {
const emote_sets = this.client && this.client.session && this.client.session.emoteSets;
if ( this._ffz_cached_sets === emote_sets )
return this._ffz_cached_emotes;
this._ffz_cached_sets = emote_sets;
const emotes = this._ffz_cached_emotes = {};
if ( emote_sets )
for(const set of emote_sets)
if ( set && set.emotes )
for(const emote of set.emotes)
if ( emote )
emotes[emote.token] = emote.id;
return emotes;
}
cls.prototype.connectHandlers = function(...args) {
if ( ! this._ffz_init ) {
const i = this;
@ -581,6 +600,42 @@ export default class ChatHook extends Module {
}
}
const old_chat = this.onChatMessageEvent;
this.onChatMessageEvent = function(e) {
if ( e && e.sentByCurrentUser ) {
try {
e.message.user.emotes = findEmotes(
e.message.body,
i.ffzGetEmotes()
);
} catch(err) {
t.log.capture(err, {extra: e});
}
}
return old_chat.call(i, e);
}
const old_action = this.onChatActionEvent;
this.onChatActionEvent = function(e) {
if ( e && e.sentByCurrentUser ) {
try {
e.message.user.emotes = findEmotes(
e.message.body.slice(8, -1),
i.ffzGetEmotes()
);
} catch(err) {
t.log.capture(err, {extra: e});
}
}
return old_action.call(i, e);
}
const old_resub = this.onResubscriptionEvent;
this.onResubscriptionEvent = function(e) {
try {
@ -626,11 +681,11 @@ export default class ChatHook extends Module {
const old_post = this.postMessage;
this.postMessage = function(e) {
const original = this._wrapped;
const original = i._wrapped;
if ( original && ! e._ffz_checked )
return this.postMessageToCurrentChannel(original, e);
return i.postMessageToCurrentChannel(original, e);
return old_post.call(this, e);
return old_post.call(i, e);
}
this._ffz_init = true;
@ -662,11 +717,6 @@ export default class ChatHook extends Module {
message.message = original.action;
else
message.message = original.message.body;
// Twitch doesn't generate a proper emote tag for echoed back
// actions, so we have to regenerate it. Fun. :D
if ( user && user.username === this.userLogin )
message.emotes = findEmotes(message.message, this.selfEmotes);
}
this.postMessage(message);
@ -903,12 +953,14 @@ export function findEmotes(msg, emotes) {
const out = {};
let idx = 0;
console.log('findEmotes', msg, emotes);
for(const part of msg.split(' ')) {
const len = split_chars(part).length;
if ( has(emotes, part) ) {
const em = emotes[part],
matches = out[em.id] = out[em.id] || [];
matches = out[em] = out[em] || [];
matches.push({
startIndex: idx,