Skip to content

Commit

Permalink
services/chat: add Chatterino preset
Browse files Browse the repository at this point in the history
Resolves #607
  • Loading branch information
bastimeyer committed Jan 28, 2021
1 parent a6aa5ed commit 127a7a9
Show file tree
Hide file tree
Showing 10 changed files with 142 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/app/locales/de/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ chat:
url:
title: Chat URL
description: Welche Chat URL verwendet werden soll.
chatterino:
label: Chatterino
attributes:
exec:
title: Chatterino Programmdatei
description: Setze einen benutzerdefinierten Chatterino Programmdateipfad.
chatty:
label: Chatty
attributes:
Expand Down
6 changes: 6 additions & 0 deletions src/app/locales/en/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ chat:
url:
title: Chat URL
description: Which Twitch chat URL to use.
chatterino:
label: Chatterino
attributes:
exec:
title: Chatterino executable
description: Set a custom Chatterino executable path.
chatty:
label: Chatty
attributes:
Expand Down
6 changes: 6 additions & 0 deletions src/app/locales/fr/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ chat:
url:
title: URL du chat
description: Quel URL du chat Twitch utiliser
chatterino:
label: Chatterino
attributes:
exec:
title: Exécutable Chatterino
description: Définir un chemin personnalisé vers l'exécutable Chatterino.
chatty:
label: Chatty
attributes:
Expand Down
6 changes: 6 additions & 0 deletions src/app/locales/pt-br/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,12 @@ chat:
url:
title: URL do chat
description: Qual URL utilizar para o chat na Twitch.
chatterino:
label: Chatterino
attributes:
exec:
title: Executável do Chatterino
description: Deine um caminho diferente para o executável do Chatterino.
chatty:
label: Chatty
attributes:
Expand Down
6 changes: 6 additions & 0 deletions src/app/locales/ru/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,12 @@ chat:
url:
title: "Ссылка на чат" #Chat URL
description: "Какую ссылку на чат Twitch использовать." #Which Twitch chat URL to use.
chatterino:
label: "Chatterino" #Chatterino
attributes:
exec:
title: "Исполняемый файл Chatterino" #Chatterino executable
description: "Пользовательский путь к Chatterino" #Set a custom Chatterino executable path.
chatty:
label: "Chatty" #Chatty
attributes:
Expand Down
6 changes: 6 additions & 0 deletions src/app/locales/zh-tw/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ chat:
url:
title: 聊天室網址
description: 要打開何種 Twitch 聊天室網址
chatterino:
label: Chatterino
attributes:
exec:
title: Chatterino 執行檔路徑
description: 設定 Chatterino 執行檔路徑
chatty:
label: Chatty
attributes:
Expand Down
23 changes: 23 additions & 0 deletions src/app/services/chat/providers/chatterino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import ChatProviderBasic from "./-basic";
import Parameter from "utils/parameters/Parameter";


/**
* @class ChatProviderChatterino
* @implements ChatProviderBasic
*/
export default class ChatProviderChatterino extends ChatProviderBasic {
// noinspection JSCheckFunctionSignatures
async _getParameters() {
return [
new Parameter( "--channels", null, "channel" )
];
}

// noinspection JSCheckFunctionSignatures
_getRuntimeContext({ name: channel }) {
return Object.assign( {}, this.context, {
channel: `t:${channel}`
});
}
}
2 changes: 2 additions & 0 deletions src/app/services/chat/providers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ChatProviderBrowser from "./browser";
import ChatProviderChromium from "./chromium";
import ChatProviderChrome from "./chrome";
import ChatProviderMsie from "./msie";
import ChatProviderChatterino from "./chatterino";
import ChatProviderChatty from "./chatty";
import ChatProviderChattyStandalone from "./chatty-standalone";
import ChatProviderCustom from "./custom";
Expand All @@ -12,6 +13,7 @@ export default {
"chromium": ChatProviderChromium,
"chrome": ChatProviderChrome,
"msie": ChatProviderMsie,
"chatterino": ChatProviderChatterino,
"chatty": ChatProviderChatty,
"chatty-standalone": ChatProviderChattyStandalone,
"custom": ChatProviderCustom
Expand Down
31 changes: 31 additions & 0 deletions src/config/chat.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,37 @@
}
]
},
"chatterino": {
"exec": {
"win32": "chatterino.exe",
"darwin": "chatterino",
"linux": [
"chatterino",
"Chatterino-x86_64.AppImage"
]
},
"fallback": {
"win32": [
"%LOCALAPPDATA%\\Programs\\Chatterino",
"%PROGRAMFILES%\\Chatterino"
],
"darwin": [
"/Applications/chatterino.app/Contents/MacOS"
],
"linux": [
"/usr/local/bin",
"/usr/bin"
]
},
"attributes": [
{
"name": "exec",
"icon": "fa-cog",
"type": "string",
"isFile": true
}
]
},
"chatty": {
"exec": {
"win32": "javaw.exe",
Expand Down
50 changes: 50 additions & 0 deletions src/test/tests/services/chat/providers/chatterino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { module, test } from "qunit";
import sinon from "sinon";

import chatProviderInjector
from "inject-loader?../launch!services/chat/providers/-provider";
import chatProviderBasicInjector
from "inject-loader?./-provider!services/chat/providers/-basic";
import chatProviderChatterinoInjector
from "inject-loader?./-provider!services/chat/providers/chatterino";


module( "services/chat/providers/chatterino", function( hooks ) {
/** @typedef {Object} TestContextChatProviderChatterino */
hooks.beforeEach( /** @this {TestContextChatProviderChatterino} */ function() {
this.launch = sinon.stub();

const { default: ChatProvider } = chatProviderInjector({
"../launch": this.launch
});

const { default: ChatProviderBasic } = chatProviderBasicInjector({
"./-provider": ChatProvider
});

const { default: ChatProviderChatterino } = chatProviderChatterinoInjector({
"./-basic": ChatProviderBasic
});

this.subject = ChatProviderChatterino;
});


test( "Default attributes", async function( assert ) {
/** @this {TestContextChatProviderChatterino} */
const provider = new this.subject();
sinon.stub( provider, "_getExec" ).resolves( "/path/to/chatterino" );

await provider.setup( {}, {} );
await provider.launch( { name: "foo" }, {} );

assert.propEqual(
this.launch.args,
[[
"/path/to/chatterino",
[ "--channels", "t:foo" ]
]],
"Spawns child process and uses the correct params"
);
});
});

0 comments on commit 127a7a9

Please sign in to comment.