diff --git a/CHANGELOG.md b/CHANGELOG.md index 2984e31..f54278e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,16 @@ # Changelog +## v0.0.25 + +Bugfixes + +* Fixed app occasionally crashing when clicking a link + +Features + +* NEW! Notifications now link directly to the VODs on Twitch.tv. No more boring searching for the right moment in the video! + ## v0.0.24 Bugfixes @@ -35,7 +45,7 @@ Future plans * Allow links to be opened in a browser * Logging into multiple Twitch.tv accounts * Saving notifications between app restarts -* Auto-reply bot, spamming bot, moderation actions etc. +* Auto-reply bot, spamming bot, moderation actions, etc. ## v0.0.18 - v0.0.21 @@ -56,7 +66,7 @@ Bugfixes Features -* You can now click the channel from notifications list +* You can now click the channel from the notifications list Bugfixes @@ -64,7 +74,7 @@ Bugfixes Future plans -* Enable auto-claming channel points +* Enable auto-claiming channel points ## v0.0.15 @@ -74,7 +84,7 @@ Github autobuild test Bugfixes -* Fixed Github autobuild +* Fixed Github auto build ## v0.0.13 @@ -127,7 +137,7 @@ Bugfixes Bugfixes -* Disable auto-scroll if user tries to scroll chat up +* Disable auto-scroll if the user tries to scroll chat up * Fixed adding a channel with uppercase letters * Small UI fixes @@ -140,7 +150,7 @@ Features Bugfixes -* Link to example page for oAuth token opens up in the browser now instead of in-app window +* Link to example page for OAuth token opens up in the browser now instead of in-app window ## v0.0.6 @@ -151,21 +161,21 @@ Small UI changes, the layout is much cleaner now! Bug fixes * Added an overlay when the app disconnects from Twitch.tv servers (they often do crash lately) -* Turn offs stream-preview on disconnect +* Turnoffs stream-preview on disconnect * Fixed adding the channel with # at the beginning ## v0.0.4 Bugfixes -* Fixed autoupdater +* Fixed auto-updater * Uploaded more appropriate screenshot ## v0.0.3 Features -* Autoupdater +* Auto updater * Tooltips Bugfixes @@ -175,7 +185,7 @@ Bugfixes ## v0.0.2 * Update README -* oAuth token input type changed from text to password +* OAuth token input type changed from text to password * Delete unnecessary files ## v0.0.1 First release diff --git a/ROADMAP.md b/ROADMAP.md index 87ff39b..b503725 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -7,5 +7,4 @@ * Logging into multiple Twitch.tv accounts / Account depended settings * Saving notifications between app restarts * Auto-reply bot, spamming bot, moderation actions etc. -* Link notifications with the VODs * Code refactoring and optimizations diff --git a/package.json b/package.json index b45af29..c393caf 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vaverix-twitch-bot", "description": "Desktop application that allows you to log-in into multiple Twitch.tv channels at once. It also notifies you when someone mentions you in any channel you choose and has couple of other extra features.", "author": "vaverix", - "version": "0.0.24", + "version": "0.0.25", "license": "MIT", "scripts": { "build": "yarn compile", diff --git a/src/main/functions.js b/src/main/functions.js index 82c6d18..6e091d1 100644 --- a/src/main/functions.js +++ b/src/main/functions.js @@ -37,6 +37,17 @@ const kraken = (opts) => { return request(Object.assign(defaults, opts)) } +const helix = (clientId, oAuth, opts) => { + let defaults = { + base: 'https://api.twitch.tv/helix/', + headers: { + Authorization: 'Bearer vjee4wlzxs9btbg3jqyx4f3md9tknp', + 'Client-ID': 'kimne78kx3ncx6brgo4mv6wki5h1ko', + }, + } + return request(Object.assign(defaults, opts)) +} + const gql = (clientId, oAuth, opts) => { let defaults = { base: 'https://gql.twitch.tv/gql', @@ -58,6 +69,13 @@ const twitchNameToUser = (username) => { }).then(({ users }) => users[0] || null) } +const getPastVideos = (clientId, oAuth, channelId) => { + return helix(clientId, oAuth, { + endpoint: `videos`, + qs: { user_id: channelId }, + }).then(({ data }) => data[0] || null) +} + // Source: https://www.thepolyglotdeveloper.com/2015/03/create-a-random-nonce-string-using-javascript/ const nonce = (length) => { var text = '' @@ -69,4 +87,13 @@ const nonce = (length) => { return text } -export { formQuerystring, request, kraken, gql, twitchNameToUser, nonce } +export { + formQuerystring, + request, + kraken, + helix, + gql, + twitchNameToUser, + getPastVideos, + nonce, +} diff --git a/src/main/twitch/twitch.js b/src/main/twitch/twitch.js index 33fdf28..ee8b258 100644 --- a/src/main/twitch/twitch.js +++ b/src/main/twitch/twitch.js @@ -1,11 +1,12 @@ -import { ipcMain } from 'electron' +import { ipcMain, shell } from 'electron' import underscore from 'underscore' import AutoLaunch from 'auto-launch' import tmi from 'tmi.js' //import discord from 'discord.js' -import { request, kraken, twitchNameToUser } from '../functions' +import { request, kraken, twitchNameToUser, nonce } from '../functions' import { startTwitchBonusCollector } from './twitchBonusCollector' import { floatingWindow } from './floatingWindow' +import { grabVodFromChannel, startVodGrabber } from './vodGrabber' const autoLauncher = new AutoLaunch({ name: require('../../../package.json').name, @@ -93,6 +94,9 @@ const startTwitchApp = (appData) => { } // Main app + ipcMain.on('app:openUrl', (e, url) => { + shell.openExternal(url) + }) ipcMain.on('app:ready', () => { if (appData.twitch && appData.twitch.disconnect) { appData.twitch.disconnect().catch(() => {}) @@ -148,6 +152,7 @@ const startTwitchApp = (appData) => { appData.mainWindow.webContents.send('app:loggedIn', appData.twitchData) getBTTVEmotes() getBadges() + startVodGrabber(appData) //startTwitchBonusCollector(appData) }) appData.twitch.on('disconnected', (reason) => { @@ -164,6 +169,7 @@ const startTwitchApp = (appData) => { tags.name = name message = String(message) let msg = { + id: nonce(12), datetime: new Date(Date.now()).toLocaleString(), username: tags.name, emotes: tags.emotes, @@ -204,6 +210,7 @@ const startTwitchApp = (appData) => { }) if (notify) { appData.mainWindow.webContents.send('channel:notification', msg) + grabVodFromChannel(msg.id, msg.channel) } } catch (error) { console.log(error) diff --git a/src/main/twitch/vodGrabber.js b/src/main/twitch/vodGrabber.js new file mode 100644 index 0000000..47a2612 --- /dev/null +++ b/src/main/twitch/vodGrabber.js @@ -0,0 +1,46 @@ +import { getPastVideos } from '../functions' + +let isVodGrabberWorking = false +let channelsToGrab = [] + +const startVodGrabber = (appData) => { + const fetchInterval = 10000 + + async function fetchVod() { + if (channelsToGrab.length > 0) { + try { + let channel = channelsToGrab[0].channel + let notificationId = channelsToGrab[0].id + if (appData.channelIds[channel]) { + let channelId = appData.channelIds[channel] + channelsToGrab.shift() + getPastVideos( + 'kimne78kx3ncx6brgo4mv6wki5h1ko', + appData.twitchData.oauth.replace('oauth:', 'Bearer '), + channelId + ).then((data) => { + appData.mainWindow.webContents.send('notifications:vod', { + id: notificationId, + channel, + channelId, + data, + }) + }) + } + } catch (error) { + console.log(error) + } + } + setTimeout(fetchVod, fetchInterval) + } + if (!isVodGrabberWorking) { + isVodGrabberWorking = true + setTimeout(fetchVod, fetchInterval) + } +} + +const grabVodFromChannel = (id, channel) => { + channelsToGrab.push({ id, channel }) +} + +export { startVodGrabber, grabVodFromChannel } diff --git a/src/renderer/App.vue b/src/renderer/App.vue index bd4271c..d7dfbf4 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -38,12 +38,7 @@ Your Twitch.tv OAuth token to access the chat. If you don't know what is it, you can get one - here. + here.
It is used to log-in to the official Twitch.tv server locally from your computer and no data is sent to our servers.
You @@ -225,7 +220,19 @@ v-html="parseMessage(item.message, item.emotes, item.channel)" class="parsed-message" >
-
{{ item.datetime }}
+
+ {{ item.datetime }} + + VOD + + {{ item.vod.duration }} + +
{ + console.log('notifications:vod') + const index = self.notifications.map((e) => e.id).indexOf(item.id) + item.data.url = item.data.url + '?t=' + item.data.duration + self.notifications[index].vod = item.data + console.log(self.notifications[index]) + }) ipcRenderer.send('app:ready', true) }, }