Skip to content

Commit

Permalink
Fixing partially the channel change reassignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Hammster committed Feb 18, 2018
1 parent a56e06b commit 09b3240
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,35 @@ export function activate(context: vscode.ExtensionContext) {
let streamData = getStreamData(activeChannel)

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

bot.on('join', () => {
console.log("try joining")
if (!joined) {
joined = true
console.log("joined")

bot.on('message', (chatter) => {
twitchChatProvider.addItem(chatter)
})
}
console.log("===================")
})

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

bot.on('part', (chatter) => {
bot.join(activeChannel)
streamData = getStreamData(activeChannel)
})

twitchChatEventEmitter.on('streamDataUpdate', (newStreamData) => {
twitchChatProvider.connectToChannel(activeChannel, newStreamData)
})
Expand All @@ -74,16 +84,15 @@ export function activate(context: vscode.ExtensionContext) {
bot.say(message)
twitchChatProvider.addItem({ message: message, username: username })
}
console.log("===================")
})
})

vscode.commands.registerCommand('twitchChat.changeChannel', () => {
vscode.window.showInputBox({ prompt: 'Enter a channelname' }).then((newChannel) => {
if (newChannel) {
bot.part(channel)
bot.join(newChannel)
activeChannel = newChannel
streamData = getStreamData(newChannel)
}
})
})
Expand Down

0 comments on commit 09b3240

Please sign in to comment.