From 92723fac91a902cf634db7e4c2866a9e01a248e2 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Wed, 8 Jan 2020 15:20:58 -0600 Subject: [PATCH 1/5] Update default datafile name --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index e131d3d..0e8f3b6 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,4 +7,4 @@ export const TWITCH_URI: string = "https://api.twitch.tv/helix/streams"; -export const DATAFILE: string = "data.temp.json"; \ No newline at end of file +export const DATAFILE: string = "data.json"; \ No newline at end of file From 7db141cb7dadcdf3cc7bee8316e7a800e62f42c6 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Thu, 9 Jan 2020 17:10:48 -0600 Subject: [PATCH 2/5] Add .data files for the gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index d0f5e81..30a389c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.json +*.data !package.json !tsconfig.json src/config.ts From 0c3567c2ca28c9b4da94760283dad92fa33d4598 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Thu, 9 Jan 2020 17:39:42 -0600 Subject: [PATCH 3/5] Fix: Make offline happen when channel is offline, not online --- src/Twitch.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Twitch.ts b/src/Twitch.ts index 2c925f6..cdab27c 100644 --- a/src/Twitch.ts +++ b/src/Twitch.ts @@ -1,7 +1,7 @@ // // Twitch.ts // -// Written by: Tyler Akins (2020/01/06 - 2020/01/08) +// Written by: Tyler Akins (2020/01/06 - 2020/01/09) // @@ -71,10 +71,10 @@ export const START_BOT = async () => { .then((response: boolean) => { // Ensure the user is live - if (response) { + if (!response) { data["offline"].total_bits += bits; data["offline"].donations.push(bits); - data["offline"].donators.push(donator) + data["offline"].donators.push(donator); } else { // Data already exists From 3aa0bfda18dcd07564a3aa2758152023d889aad7 Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Thu, 9 Jan 2020 17:40:10 -0600 Subject: [PATCH 4/5] Update way datafile is loaded. --- src/utils.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index e4a503e..1d3734c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,17 +1,17 @@ // // utils.ts // -// Written by: Tyler Akins (2020/01/06 - 2020/01/08) +// Written by: Tyler Akins (2020/01/06 - 2020/01/09) // import { readFileSync, writeFileSync } from "fs" -import { INDENT_DEPTH } from "./config"; -import { DATAFILE } from "./constants"; +import { INDENT_DEPTH, CHANNEL } from "./config"; +import { DATAPATH } from "./constants"; -export const GET_FORMATTED_DATE = () => { +export const GET_FORMATTED_DATE = (time=false) => { let date = new Date(); let year = date.getFullYear(); @@ -26,7 +26,7 @@ export const GET_FORMATTED_DATE = () => { export const LOAD_DATA = (): data => { - let buffer = readFileSync(DATAFILE); + let buffer = readFileSync(`${DATAPATH}/${CHANNEL}.data`); // @ts-ignore return JSON.parse(buffer); @@ -36,7 +36,7 @@ export const LOAD_DATA = (): data => { export const WRITE_DATA = (data: data) => { writeFileSync( - DATAFILE, + `${DATAPATH}/${CHANNEL}.data`, JSON.stringify(data, null, INDENT_DEPTH) ); }; \ No newline at end of file From 11bb38dcbf62f2452cec4a884751f669eb329e0b Mon Sep 17 00:00:00 2001 From: Tyler-A Date: Thu, 9 Jan 2020 17:40:27 -0600 Subject: [PATCH 5/5] Change DATAFILE to DATAPATH --- src/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constants.ts b/src/constants.ts index 0e8f3b6..a5aca74 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -7,4 +7,4 @@ export const TWITCH_URI: string = "https://api.twitch.tv/helix/streams"; -export const DATAFILE: string = "data.json"; \ No newline at end of file +export const DATAPATH: string = "./data"; \ No newline at end of file