Skip to content

Commit

Permalink
Update to version 0.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
vaverix committed Aug 16, 2021
1 parent cf7cd5d commit 8e70c45
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 23 deletions.
30 changes: 20 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

Expand All @@ -56,15 +66,15 @@ Bugfixes

Features

* You can now click the channel from notifications list
* You can now click the channel from the notifications list

Bugfixes

* Changelog visual fixes

Future plans

* Enable auto-claming channel points
* Enable auto-claiming channel points

## v0.0.15

Expand All @@ -74,7 +84,7 @@ Github autobuild test

Bugfixes

* Fixed Github autobuild
* Fixed Github auto build

## v0.0.13

Expand Down Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
1 change: 0 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
29 changes: 28 additions & 1 deletion src/main/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = ''
Expand All @@ -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,
}
11 changes: 9 additions & 2 deletions src/main/twitch/twitch.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(() => {})
Expand Down Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
46 changes: 46 additions & 0 deletions src/main/twitch/vodGrabber.js
Original file line number Diff line number Diff line change
@@ -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 }
30 changes: 22 additions & 8 deletions src/renderer/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@
<span class="helper-text"
>Your Twitch.tv OAuth token to access the chat. If you don't
know what is it, you can get one
<a
@click="open('https://twitchapps.com/tmi/')"
href
target="_blank"
>here</a
>.
<a @click="open('https://twitchapps.com/tmi/')">here</a>.
<br />
It is used to log-in to the official Twitch.tv server locally
from your computer and no data is sent to our servers.<br />You
Expand Down Expand Up @@ -225,7 +220,19 @@
v-html="parseMessage(item.message, item.emotes, item.channel)"
class="parsed-message"
></span>
<div class="datetime">{{ item.datetime }}</div>
<div class="datetime">
{{ item.datetime }}
<span v-if="item.vod" class="pull-right">
<a @click="open(item.vod.url)" class="link text-white"
>VOD
<img
width="8"
height="8"
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAA80lEQVQokZ2SPUoEQRCFvxlGkEoEDfzB1DuYiLFgZCwoCCIGGmwo7LIsnkE2MBRDr6BXMBQMXYQxEqrBQJ/02gO6MO3qg66CV/VRL+iirusNM7sBFvipJ2AVKIEamE+dEMJjIekDuAeGQJFQAa/AVfJ2gRegC6yPN9xdknYk8cvblPQu6c7dR2W6sEheR8AtcAicAssNWGSwCF0AA+ASWIlBm6jHLTEP9KXzb17l7jM58CRB/cmZu1NmIr4BZ0Bvwt8GHqoMOGzxl4C13MU2hVj+A47VgM9/YEaxVGYWeweYnRLci0z85Ftmdg3MTQmGEML+J4NwsYmEUcPLAAAAAElFTkSuQmCC"
/></a>
{{ item.vod.duration }}
</span>
</div>
</div>
<img
v-if="isAutoScrollAllowed()"
Expand Down Expand Up @@ -715,7 +722,7 @@ export default {
},
methods: {
open(b) {
require('electron').shell.openExternal(b)
ipcRenderer.send('app:openUrl', b)
},
logIn() {
this.disableLogin = true
Expand Down Expand Up @@ -1182,6 +1189,13 @@ export default {
console.log('options:list')
console.log(self.options)
})
ipcRenderer.on('notifications:vod', (e, item) => {
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)
},
}
Expand Down

0 comments on commit 8e70c45

Please sign in to comment.