From 581be83bd65a2f961de9f090f6b9c4d63ca557b6 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 4 May 2019 15:35:10 -0400 Subject: [PATCH 1/7] Fix an error in logging errors 4head --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 1074307..cb3a224 100644 --- a/main.js +++ b/main.js @@ -42,7 +42,7 @@ function autoUpdate() { autoUpdater.on('error', err => { const errorLog = `${process.execPath}/error.log`; - fs.writeFile(errorLog, `There was a problem updating the application: ${err}`, 'a+', (err) => { + fs.appendFile(errorLog, `There was a problem updating the application: ${err}`, (err) => { }); }) From 4983753759681d2c2a62388243d6e794dd4af331 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 4 May 2019 17:56:48 -0400 Subject: [PATCH 2/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c04329e..7f24041 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NPM Version](https://img.shields.io/npm/v/npm.svg?style=flat)](https://www.npmjs.com/) [![Build Status](https://travis-ci.com/cairthenn/Blink.svg?branch=master)](https://travis-ci.com/cairthenn/Blink) [![Build status](https://ci.appveyor.com/api/projects/status/0rf9ysedohiyy58w?svg=true)](https://ci.appveyor.com/project/cairthenn/blink-cxr13) -[![Discord Chat](https://img.shields.io/discord/551637138093899786.svg?logo=discord&colorB=7289da)](https://discord.gg/kpMknTN) +[![Discord Chat](https://img.shields.io/discord/551637138093899786.svg?logo=discord&colorB=7289da)](https://discord.gg/TpdwZcp) # Installation From 480280baf1b57fbcdfa77a224a678179f59418c6 Mon Sep 17 00:00:00 2001 From: Mark Date: Sat, 4 May 2019 17:57:29 -0400 Subject: [PATCH 3/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7f24041..100cbef 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![NPM Version](https://img.shields.io/npm/v/npm.svg?style=flat)](https://www.npmjs.com/) [![Build Status](https://travis-ci.com/cairthenn/Blink.svg?branch=master)](https://travis-ci.com/cairthenn/Blink) [![Build status](https://ci.appveyor.com/api/projects/status/0rf9ysedohiyy58w?svg=true)](https://ci.appveyor.com/project/cairthenn/blink-cxr13) -[![Discord Chat](https://img.shields.io/discord/551637138093899786.svg?logo=discord&colorB=7289da)](https://discord.gg/TpdwZcp) +[![Discord Chat](https://img.shields.io/discord/515164869880840192.svg?logo=discord&colorB=7289da)](https://discord.gg/TpdwZcp) # Installation From 14436522c6fb5d4fbdbfa32223c03d8872a9f971 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 22 Aug 2019 17:56:40 -0400 Subject: [PATCH 4/7] Remove deprecated twitch API calls, prep for whispers/mentions --- main.js | 7 ++-- src/app/twitch.service.ts | 84 ++++++++++++++++++++++++++------------- 2 files changed, 60 insertions(+), 31 deletions(-) diff --git a/main.js b/main.js index cb3a224..d32c66d 100644 --- a/main.js +++ b/main.js @@ -98,9 +98,10 @@ function launchApplication() { window.show(); }); - // if(process.env.NODE_ENV == 'dev') { - // window.webContents.toggleDevTools(); - // } + if(process.env.NODE_ENV == 'dev') { + window.webContents.toggleDevTools(); + } + window.loadFile('./dist/index.html'); if(!firstRun && process.env.NODE_ENV != 'dev' && process.platform == 'win32') { diff --git a/src/app/twitch.service.ts b/src/app/twitch.service.ts index beea04d..b4b2207 100644 --- a/src/app/twitch.service.ts +++ b/src/app/twitch.service.ts @@ -4,6 +4,7 @@ import { IrcService } from './irc.service'; import CryptoJS from 'crypto-js'; import * as qs from 'querystring'; import { Web } from './web'; +import { ChatService } from './chat.service'; const authBase = 'https://id.twitch.tv/oauth2'; const authUrl = `${authBase}/authorize`; @@ -106,6 +107,8 @@ export class TwitchService { public username: string; public usernameLower: string; + public whispers: ChatService; + public mentions: ChatService; private authWindow; private cheers: any = {}; @@ -115,6 +118,7 @@ export class TwitchService { private emotes: any = {}; private setNames: any = {}; private validation: any = {}; + private userIdMap: any = {}; private enckey: string; private loggedIn: boolean; private emoteCheck: number; @@ -228,6 +232,7 @@ export class TwitchService { return promise.then((auth: any) => { return Web.get(validateUrl, { headers: { + Accept: 'application/vnd.twitchtv.v5+json', Authorization : `OAuth ${auth.access_token}` } }).then(validatation => { @@ -235,7 +240,7 @@ export class TwitchService { this.usernameLower = validatation.login; this.enckey = CryptoJS.AES.encrypt(auth.access_token, validatation.login); this.loggedIn = true; - + const displayNamePromise = this.getChannel(validatation.login).then(channel => { this.username = channel.display_name; return true; @@ -247,47 +252,69 @@ export class TwitchService { const ircPromise = this.irc.connect(validatation.login, auth.access_token).then(() => true).catch(err => false); const emotePromise = this.getEmotes().then(() => true).catch(err => false); return Promise.all([displayNamePromise, ircPromise, emotePromise]).then(results => { - console.log(results); return results.every(x => x); }).catch(err => { console.log(`Error fetching channel info: ${err}`); return false; }); }); }).catch(err => { console.log(`Error fetching channel info: ${err}`); return false; }); } - public getStream(id: string, update?: boolean) { - const fetch = update || this.streams[id] ? this.needsUpdate(this.streams[id][1], 'streams') : true; - if (!fetch) { - return Promise.resolve(this.streams[id][0]); - } - - return Web.get(`${twitchApi}/${apiVersion}/${streamEp}/${id}`, { - headers: { - Authorization : `OAuth ${this.key}` + public getStream(name: string, update?: boolean) { + + return this.getChannelID(name).then(id => { + const fetch = update || this.streams[id] ? this.needsUpdate(this.streams[id][1], 'streams') : true; + if (!fetch) { + return Promise.resolve(this.streams[id][0]); } - }).then(stream => { - const info = stream.stream || {}; - info.live = info.stream_type === 'live'; - info.vod = info.stream_type === 'playlist'; - this.streams[id] = [ info, Date.now() ]; - return info; + + return Web.get(`${twitchApi}/${apiVersion}/${streamEp}/${id}`, { + headers: { + Accept: 'application/vnd.twitchtv.v5+json', + Authorization : `OAuth ${this.key}` + } + }).then(stream => { + const info = stream.stream || {}; + info.live = info.stream_type === 'live'; + info.vod = info.stream_type === 'playlist'; + this.streams[id] = [ info, Date.now() ]; + return info; + }); }); } - public getChannel(id: string, update?: boolean) { + private getChannelID(name: string) { - const fetch = update || this.channels[id] ? this.needsUpdate(this.channels[id][1], 'channels') : true; - if (!fetch) { - return Promise.resolve(this.channels[id][0]); + if (name in this.userIdMap) { + return Promise.resolve(this.userIdMap[name]); } - return Web.get(`${twitchApi}/${apiVersion}/${channelEp}/${id}`, { + return Web.get(`${twitchApi}/helix/users?login=${name}`, { headers: { - Authorization : `OAuth ${this.key}` + Authorization : `Bearer ${this.key}` + } + }).then(response => { + return this.userIdMap[name] = response.data[0].id; + }) + + } + + public getChannel(name: string, update?: boolean) { + + return this.getChannelID(name).then(id => { + const fetch = update || this.channels[id] ? this.needsUpdate(this.channels[id][1], 'channels') : true; + if (!fetch) { + return Promise.resolve(this.channels[id][0]); } - }).then(channel => { - channel.signup = new Date(channel.created_at).toDateString(); - this.channels[id] = [ channel, Date.now() ]; - return channel; + + return Web.get(`${twitchApi}/${apiVersion}/${channelEp}/${id}`, { + headers: { + Accept: 'application/vnd.twitchtv.v5+json', + Authorization : `OAuth ${this.key}` + } + }).then(channel => { + channel.signup = new Date(channel.created_at).toDateString(); + this.channels[id] = [ channel, Date.now() ]; + return channel; + }); }); } @@ -336,8 +363,9 @@ export class TwitchService { return Promise.resolve(this.emotes); } - return Web.get(`${twitchApi}/${apiVersion}/users/${this.usernameLower}/emotes`, { + return Web.get(`${twitchApi}/${apiVersion}/users/${this.validation.user_id}/emotes`, { headers: { + Accept: 'application/vnd.twitchtv.v5+json', Authorization : `OAuth ${this.key}` } }).then(emotes => { From 5d9ce4bde35fc108eb1e724f614a4cf06faba723 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 22 Aug 2019 18:00:32 -0400 Subject: [PATCH 5/7] Fix broken /host command --- src/app/twitch.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/twitch.service.ts b/src/app/twitch.service.ts index b4b2207..f970faa 100644 --- a/src/app/twitch.service.ts +++ b/src/app/twitch.service.ts @@ -11,7 +11,7 @@ const authUrl = `${authBase}/authorize`; const validateUrl = `${authBase}/validate`; const revokeUrl = `${authBase}/revoke`; const redirect = 'https://cairthenn.com'; -const scopes = 'chat:edit chat:read whispers:edit whispers:read channel:moderate user_subscriptions'; +const scopes = 'chat:edit chat:read whispers:edit whispers:read channel:moderate user_subscriptions channel_editor'; const clientId = 'ut8pnp247zcvfj7gga2lxo8kp2d9lz'; const badgeChannelUrl = 'https://badges.twitch.tv/v1/badges/channels/'; From 399af1c0c3d14863585f63ab5b15c517a4e69333 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 22 Aug 2019 18:03:30 -0400 Subject: [PATCH 6/7] Actually ignore ignored users --- src/app/chat.service.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/chat.service.ts b/src/app/chat.service.ts index 66706ff..671c6e0 100644 --- a/src/app/chat.service.ts +++ b/src/app/chat.service.ts @@ -449,6 +449,10 @@ export class ChatService { const message = Message.fromIncoming(original, params, this.emotes, this.cheers, this.settings, this.usernameLower); + if(message.ignore) { + return; + } + if (message.highlight && !this.active) { this.mentions++; if (this.settings.flash) { From 17d13f40ff595c4a16fc85da3b51e0a6cc96ffe6 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 22 Aug 2019 18:04:54 -0400 Subject: [PATCH 7/7] 1.2.9 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 48c5f44..f0ef520 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "Blink", - "version": "1.2.8", + "version": "1.2.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8678ca6..d52177f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "Blink", - "version": "1.2.8", + "version": "1.2.9", "description": "Blink", "license": "GPL-3.0", "main": "main.js",