From 55f65c154675818a1f24bdcf617aa92b8c1843bd Mon Sep 17 00:00:00 2001 From: Hans Koch Date: Wed, 31 Jan 2018 00:39:13 +0100 Subject: [PATCH] Added channel switch and open twitch stream functions --- package.json | 26 +++++++++++-- resources/dark/link.svg | 68 ++++++++++++++++++++++++++++++++++ resources/dark/string.svg | 75 +++++++++++++++++++++++++++++++++++++- resources/light/link.svg | 68 ++++++++++++++++++++++++++++++++++ resources/light/string.svg | 75 +++++++++++++++++++++++++++++++++++++- src/extension.ts | 28 +++++++++++--- 6 files changed, 329 insertions(+), 11 deletions(-) create mode 100644 resources/dark/link.svg create mode 100644 resources/light/link.svg diff --git a/package.json b/package.json index ae2a400..e8c09a2 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "twitch-chat", "displayName": "Twitch Chat", "description": "VS code Extension for Twitch Chat Integration", - "version": "0.1.0", + "version": "0.2.0", "publisher": "hammster1911", "repository": { "type": "git", @@ -33,6 +33,22 @@ "dark": "resources/dark/string.svg", "light": "resources/light/string.svg" } + }, + { + "command": "twitchChat.openActiveStream", + "title": "Twitch Chat: Open active stream", + "icon": { + "dark": "resources/dark/link.svg", + "light": "resources/light/link.svg" + } + }, + { + "command": "twitchChat.changeChannel", + "title": "Twitch Chat: Change selected channel", + "icon": { + "dark": "resources/dark/link.svg", + "light": "resources/light/link.svg" + } }], "configuration": { "type": "object", @@ -65,8 +81,12 @@ { "command": "twitchChat.sendMessage", "when": "view == twitchChat", - "group": "navigation", - "tile": "test" + "group": "navigation" + }, + { + "command": "twitchChat.openActiveStream", + "when": "view == twitchChat", + "group": "navigation" } ] } diff --git a/resources/dark/link.svg b/resources/dark/link.svg new file mode 100644 index 0000000..fa170b7 --- /dev/null +++ b/resources/dark/link.svg @@ -0,0 +1,68 @@ + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/resources/dark/string.svg b/resources/dark/string.svg index e08a57f..55ae622 100644 --- a/resources/dark/string.svg +++ b/resources/dark/string.svg @@ -1 +1,74 @@ - \ No newline at end of file + + + + + + image/svg+xml + + + + + + + + + + + A + diff --git a/resources/light/link.svg b/resources/light/link.svg new file mode 100644 index 0000000..84da16a --- /dev/null +++ b/resources/light/link.svg @@ -0,0 +1,68 @@ + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/resources/light/string.svg b/resources/light/string.svg index 943e69c..eb5be2d 100644 --- a/resources/light/string.svg +++ b/resources/light/string.svg @@ -1 +1,74 @@ - \ No newline at end of file + + + + + + image/svg+xml + + + + + + + + + + + A + diff --git a/src/extension.ts b/src/extension.ts index e50533b..2626719 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -12,6 +12,8 @@ export function activate(context: vscode.ExtensionContext) { const username = config.username const oauth = config.oauth let joined = false + let activeChannel = channel + if (channel && username && oauth) { const bot = new twitchBot({ @@ -23,8 +25,8 @@ export function activate(context: vscode.ExtensionContext) { bot.on('join', () => { if (!joined) { joined = true - bot.on('message', (x) => { - twitchChatProvider.addItem(x) + bot.on('message', (chatter) => { + twitchChatProvider.addItem(chatter) }) } }) @@ -34,14 +36,28 @@ export function activate(context: vscode.ExtensionContext) { }) vscode.commands.registerCommand('twitchChat.sendMessage', () => { - vscode.window.showInputBox({ prompt: "Enter a Chat message" }).then((x) => { - if(x) { - bot.say(x) - twitchChatProvider.addItem({message:x, username:username}) + vscode.window.showInputBox({ prompt: "Enter a Chat message" }).then((message) => { + if(message) { + bot.say(message) + twitchChatProvider.addItem({message:message, username:username}) } }) }) + vscode.commands.registerCommand('twitchChat.changeChannel', () => { + vscode.window.showInputBox({ prompt: "Enter a channelname" }).then((newChannel) => { + if(newChannel) { + bot.part(channel) + bot.join(newChannel) + activeChannel = newChannel + } + }) + }) + + vscode.commands.registerCommand('twitchChat.openActiveStream', () => { + vscode.commands.executeCommand('vscode.open', vscode.Uri.parse('https://www.twitch.tv/' + activeChannel)) + }) + vscode.window.registerTreeDataProvider('twitchChat', twitchChatProvider) } else { vscode.window.showWarningMessage('TwitchChat need additional configuration')