From 86b0b624f7724bbe574132e02a0f609d10d655e4 Mon Sep 17 00:00:00 2001 From: SirStendec Date: Thu, 27 Jun 2019 23:19:05 -0400 Subject: [PATCH] 4.6.0 * Added: Custom Chat Commands now have an option to paste their output into chat input rather than immediately sending the message. * Added: The option to tab-complete emotes without the use of a colon (:). Please note that this feature still has limitations due to limitations in how Twitch's tab-completion system is implemented, and may not work as you expect. * Added: The number of results from emote tab-completion will now be limited to 25 by default to mitigate its performance impact. This may be disabled in settings. --- package.json | 2 +- src/experiments.js | 12 ++++----- .../chat/actions/components/edit-chat.vue | 26 +++++++++++++++++-- src/modules/chat/actions/index.jsx | 5 ++++ src/modules/chat/actions/types.jsx | 8 ++++-- .../twitch-twilight/modules/chat/input.jsx | 18 ++++++++++++- 6 files changed, 59 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index a026974f..2827619c 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "frankerfacez", "author": "Dan Salvato LLC", - "version": "4.5.5", + "version": "4.6.0", "description": "FrankerFaceZ is a Twitch enhancement suite.", "license": "Apache-2.0", "scripts": { diff --git a/src/experiments.js b/src/experiments.js index 935babfd..beea2da5 100644 --- a/src/experiments.js +++ b/src/experiments.js @@ -149,13 +149,13 @@ export default class ExperimentManager extends Module { if ( window.__twilightSettings ) return window.__twilightSettings.experiments; - const core = this.resolve('site').getCore(); + const core = this.resolve('site')?.getCore(); return core && core.experiments.experiments; } usingTwitchExperiment(key) { - const core = this.resolve('site').getCore(); + const core = this.resolve('site')?.getCore(); return core && has(core.experiments.assignments, key) } @@ -165,7 +165,7 @@ export default class ExperimentManager extends Module { overrides[key] = value; Cookie.set(OVERRIDE_COOKIE, overrides, COOKIE_OPTIONS); - const core = this.resolve('site').getCore(); + const core = this.resolve('site')?.getCore(); if ( core ) core.experiments.overrides[key] = value; @@ -181,7 +181,7 @@ export default class ExperimentManager extends Module { delete overrides[key]; Cookie.set(OVERRIDE_COOKIE, overrides, COOKIE_OPTIONS); - const core = this.resolve('site').getCore(); + const core = this.resolve('site')?.getCore(); if ( core ) delete core.experiments.overrides[key]; @@ -194,7 +194,7 @@ export default class ExperimentManager extends Module { } getTwitchAssignment(key) { - const core = this.resolve('site').getCore(), + const core = this.resolve('site')?.getCore(), exps = core && core.experiments; if ( ! exps ) @@ -235,7 +235,7 @@ export default class ExperimentManager extends Module { } _rebuildTwitchKey(key, is_set, new_val) { - const core = this.resolve('site').getCore(), + const core = this.resolve('site')?.getCore(), exps = core.experiments, old_val = has(exps.assignments, key) ? diff --git a/src/modules/chat/actions/components/edit-chat.vue b/src/modules/chat/actions/components/edit-chat.vue index ad86997b..6d50312f 100644 --- a/src/modules/chat/actions/components/edit-chat.vue +++ b/src/modules/chat/actions/components/edit-chat.vue @@ -1,12 +1,12 @@ \ No newline at end of file diff --git a/src/modules/chat/actions/index.jsx b/src/modules/chat/actions/index.jsx index f47a6d02..72b28d24 100644 --- a/src/modules/chat/actions/index.jsx +++ b/src/modules/chat/actions/index.jsx @@ -636,6 +636,11 @@ export default class Actions extends Module { } + pasteMessage(room, message) { + return this.resolve('site.chat.input').pasteMessage(room, message); + } + + sendMessage(room, message) { return this.resolve('site.chat').sendMessage(room, message); } diff --git a/src/modules/chat/actions/types.jsx b/src/modules/chat/actions/types.jsx index 2f8f3973..a0e2ad32 100644 --- a/src/modules/chat/actions/types.jsx +++ b/src/modules/chat/actions/types.jsx @@ -63,7 +63,8 @@ export const chat = { required_context: ['room'], defaults: { - command: '@{{user.login}} HeyGuys' + command: '@{{user.login}} HeyGuys', + paste: false }, title: 'Chat Command', @@ -86,7 +87,10 @@ export const chat = { click(event, data) { const msg = this.replaceVariables(data.options.command, data); - this.sendMessage(data.room.login, msg); + if ( data.options.paste ) + this.pasteMessage(data.room.login, msg); + else + this.sendMessage(data.room.login, msg); } } diff --git a/src/sites/twitch-twilight/modules/chat/input.jsx b/src/sites/twitch-twilight/modules/chat/input.jsx index 0a6bb4e7..2037f18e 100644 --- a/src/sites/twitch-twilight/modules/chat/input.jsx +++ b/src/sites/twitch-twilight/modules/chat/input.jsx @@ -251,7 +251,7 @@ export default class Input extends Module { } } - + // eslint-disable-next-line class-methods-use-this getTwitchEmoteSuggestions(input, inst) { const hydratedEmotes = inst.hydrateEmotes(inst.props.emotes); @@ -352,4 +352,20 @@ export default class Input extends Module { return results; } + + pasteMessage(room, message) { + for(const inst of this.ChatInput.instances) { + if ( inst?.props?.channelLogin !== room ) + continue; + + if ( ! inst.autocompleteInputRef || ! inst.state ) + return; + + if ( inst.state.value ) + message = `${inst.state.value} ${message}`; + + inst.autocompleteInputRef.setValue(message); + inst.autocompleteInputRef.componentRef?.focus?.(); + } + } }