Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammster committed Jan 28, 2018
0 parents commit 53a5846
Show file tree
Hide file tree
Showing 16 changed files with 2,165 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
out
node_modules
48 changes: 48 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// A launch configuration that compiles the extension and then opens it inside a new window
{
"version": "0.1.0",
"configurations": [
{
"name": "Launch Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/src/**/*.js"
],
"preLaunchTask": "npm"
},
{
"name": "Launch Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/out/test/**/*.js"
],
"preLaunchTask": "npm"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Extension Host",
"protocol": "inspector",
"port": 5870,
"restart": true,
"outFiles": [
"${workspaceRoot}/out/src"
]
}
]
}
10 changes: 10 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
"typescript.tsdk": "./node_modules/typescript/lib" // we want to use the TS server from our node_modules folder to control its version
}
30 changes: 30 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Available variables which can be used inside of strings.
// ${workspaceRoot}: the root folder of the team
// ${file}: the current opened file
// ${fileBasename}: the current opened file's basename
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process

// A task runner that calls a custom npm script that compiles the extension.
{
"version": "0.1.0",

// we want to run npm
"command": "npm",

// the command is a shell script
"isShellCommand": true,

// show the output window only if unrecognized errors occur.
"showOutput": "silent",

// we run the custom script "compile" as defined in package.json
"args": ["run", "compile", "--loglevel", "silent"],

// The tsc compiler is started in watching mode
"isBackground": true,

// use the standard tsc in watch mode problem matcher to find compile problems in the output.
"problemMatcher": "$tsc-watch"
}
9 changes: 9 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
**/*.map
.gitignore
tsconfig.json
vsc-extension-quickstart.md
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Twitch Chat for Visual Studio Code

[![Visual Studio Marketplace](https://img.shields.io/vscode-marketplace/v/hammster1911.twitch-chat.svg)](https://marketplace.visualstudio.com/items?itemName=hammster1911.twitch-chat)
[![Installs](https://img.shields.io/vscode-marketplace/d/hammster1911.twitch-chat.svg)](https://marketplace.visualstudio.com/items?itemName=hammster1911.twitch-chat)
[![Rating](https://img.shields.io/vscode-marketplace/r/hammster1911.twitch-chat.svg)](https://marketplace.visualstudio.com/items?itemName=hammster1911.twitch-chat)

## Features

Adds a Chat log to the Explorer view
Send chat messages without leaving VScode

![Screenshot](https://github.com/hammster1911/twitch-chat/raw/master/src/media/example.png "Screenshot showing the twitch-chat extension")


## Extension Settings

These settings have to be

```json
{
// Generate a token here: http://www.twitchapps.com/tmi
"twitchChat.oauth": "************",
"twitchChat.username": "TwitchUserName",
"twitchChat.channel": "channelname",
// Optional: Set the amount of chatmessages that are shown
"twitchChat.historysize": 20
}
```
## Known Issues

The Chatlogs are limited to a set height, therefore text is cut off and you have to read the content by hovering the entry
Icons are not displayed
Binary file added media/example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/twitchChat.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions media/twitchChat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
83 changes: 83 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"name": "twitch-chat",
"displayName": "Twitch Chat",
"description": "VS code Extension for Twitch Chat Integration",
"version": "0.1.0",
"publisher": "hammster1911",
"engines": {
"vscode": "^1.13.0"
},
"categories": [
"Other"
],
"activationEvents": [
"onView:twitchChat"
],
"main": "./out/src/extension",
"icon": "media/twitchChat.png",
"contributes": {
"views": {
"explorer": [{
"id": "twitchChat",
"name": "Twitch Chat"
}]
},
"commands": [{
"command": "twitchChat.sendMessage",
"title": "Twitch Chat: Send Chat message",
"icon": {
"dark": "resources/dark/string.svg",
"light": "resources/light/string.svg"
}
}],
"configuration": {
"type": "object",
"title": "Example configuration",
"properties": {
"twitchChat.historysize": {
"type": "number",
"default": 20,
"description": "Amount of chatmessages that are keept in cache for the sesssion"
},
"twitchChat.oauth": {
"type": "string",
"default": "",
"description": "DONT SHOW THIS IN STREAM!!!!, Your twitch token, Generate a token here: http://www.twitchapps.com/tmi"
},
"twitchChat.username": {
"type": "string",
"default": "",
"description": "Your Twitch username."
},
"twitchChat.channel": {
"type": "string",
"default": "",
"description": "The channel name. For Twitch, use [your channel/user name] without a hashtag."
}
}
},
"menus": {
"view/title": [
{
"command": "twitchChat.sendMessage",
"when": "view == twitchChat",
"group": "navigation",
"tile": "test"
}
]
}
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"postinstall": "node ./node_modules/vscode/bin/install"
},
"devDependencies": {
"@types/node": "9.4.0",
"typescript": "^2.6.2",
"vscode": "^1.1.10"
},
"dependencies": {
"twitch-bot": "^1.2.2"
}
}
1 change: 1 addition & 0 deletions resources/dark/string.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/light/string.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
'use strict'

import * as vscode from 'vscode'
import { TwitchChatProvider } from './twitchChat'
import * as twitchBot from 'twitch-bot'

export function activate(context: vscode.ExtensionContext) {
const rootPath = vscode.workspace.rootPath
const config = vscode.workspace.getConfiguration('twitchChat')
const twitchChatProvider = new TwitchChatProvider(rootPath, config)
const channel = config.channel
const username = config.username
const oauth = config.oauth
let joined = false

if (channel && username && oauth) {
const bot = new twitchBot({
username: username,
oauth: oauth,
channels: [channel]
})

bot.on('join', () => {
if (!joined) {
joined = true
bot.on('message', (x) => {
twitchChatProvider.addItem(x)
})
}
})

bot.on("error", err => {
vscode.window.showErrorMessage(err)
})

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.registerTreeDataProvider('twitchChat', twitchChatProvider)
} else {
vscode.window.showWarningMessage('TwitchChat need additional configuration')
}
}
Loading

0 comments on commit 53a5846

Please sign in to comment.