@livecord/notify
Advanced tools
Comparing version 1.1.2 to 1.1.3
const { Twitch } = require('../src/index'); | ||
const twitch = new Twitch({ | ||
client: { | ||
id: "", | ||
token: "" | ||
id: "0w3w9kd3xgome2t3kybau47z9lhza9", | ||
token: "xgo7bj4lydp649bgl8qmw02ozcusas" | ||
}, | ||
@@ -13,3 +13,3 @@ useDatabase: true, | ||
twitch.on('ready', (ready) => { | ||
twitch.follow('rraenee'); | ||
twitch.follow('jrokezftw'); | ||
console.log('Twitch connected at: ', ready); | ||
@@ -16,0 +16,0 @@ }); |
@@ -1,1 +0,26 @@ | ||
{"channels":["clqu_","rraenee"]} | ||
{ | ||
"lives": [ | ||
{ | ||
"id": "45614822620", | ||
"user_id": "155642616", | ||
"user_login": "jrokezftw", | ||
"user_name": "JrokezFTW", | ||
"game_id": "509658", | ||
"game_name": "Just Chatting", | ||
"type": "live", | ||
"title": "Heeeey :) | insta:jrokez !trendyol", | ||
"viewer_count": 5690, | ||
"started_at": "2022-06-19T14:39:34Z", | ||
"language": "tr", | ||
"thumbnail_url": "https://static-cdn.jtvnw.net/previews-ttv/live_user_jrokezftw-{width}x{height}.jpg", | ||
"tag_ids": [ | ||
"f08d5873-f0c7-4912-94ba-a41933b4c141" | ||
], | ||
"is_mature": true | ||
} | ||
], | ||
"channels": [ | ||
"pqueen", | ||
"jrokezftw" | ||
] | ||
} |
{ | ||
"name": "@livecord/notify", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Notifier for Youtube and Twitch.", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -36,4 +36,7 @@ const EventEmitter = require('events'); | ||
}); | ||
db?.lives?.forEach(channel => { | ||
if (!this.lives.includes(channel)) this.lives.push(channel); | ||
}); | ||
} else { | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ channels: [] }, 2, null)); | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ lives: [], channels: [] }, null, 2)); | ||
} | ||
@@ -55,7 +58,28 @@ } | ||
let findLive = this.lives.find(element => element.user_login === channel?.toLowerCase()); | ||
let db = JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives; | ||
if(isLive && isLive.type === 'live') { | ||
if(db.find(element => element.user_login === isLive?.user_login?.toLowerCase())) return; | ||
if(findLive) return; | ||
this.lives.push(isLive); | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives, | ||
isLive | ||
], | ||
channels: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels, | ||
], | ||
}, null, 2)); | ||
return this.emit('live', isLive); | ||
} else { | ||
if(db.find(element => element.user_login === findLive?.user_login?.toLowerCase())) { | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives?.filter(element => element.user_login !== findLive?.user_login?.toLowerCase()), | ||
], | ||
channels: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels, | ||
], | ||
}, null, 2)); | ||
} | ||
if(findLive) { | ||
@@ -82,2 +106,5 @@ this.emit('offline', findLive); | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives | ||
], | ||
channels: [ | ||
@@ -87,3 +114,3 @@ ...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels, | ||
], | ||
}, 2, null)); | ||
}, null, 2)); | ||
return this.channels.push(channel?.toLowerCase()); | ||
@@ -98,2 +125,5 @@ } else { | ||
fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives | ||
], | ||
channels: [ | ||
@@ -103,3 +133,3 @@ ...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels, | ||
], | ||
}, 2, null)); | ||
}, null, 2)); | ||
return this.channels.push(c?.toLowerCase()); | ||
@@ -121,6 +151,9 @@ } else { | ||
return fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives | ||
], | ||
channels: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels?.filter(el => el !== channel?.toLowerCase()) | ||
], | ||
}, 2, null)); | ||
}, null, 2)); | ||
} else { | ||
@@ -135,2 +168,5 @@ return this.channels = this.channels.filter(el => el !== channel?.toLowerCase()); | ||
return fs.writeFileSync('livecord-twitch.json', JSON.stringify({ | ||
lives: [ | ||
...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.lives | ||
], | ||
channels: [ | ||
@@ -137,0 +173,0 @@ ...JSON.parse(fs.readFileSync('livecord-twitch.json'))?.channels?.filter(el => el !== c?.toLowerCase()) |
@@ -57,3 +57,3 @@ const EventEmitter = require('events'); | ||
] | ||
}, 2, null)); | ||
}, null, 2)); | ||
this.postedVideos.push($.id); | ||
@@ -88,3 +88,3 @@ return this.emit('upload', $); | ||
] | ||
}, 2, null)); | ||
}, null, 2)); | ||
this.channels.push(channel); | ||
@@ -108,3 +108,3 @@ return this.ws.emit('newChannel', channel); | ||
] | ||
}, 2, null)); | ||
}, null, 2)); | ||
return this.channels.push(c); | ||
@@ -132,3 +132,3 @@ } else { | ||
] | ||
}, 2, null)); | ||
}, null, 2)); | ||
} else { | ||
@@ -135,0 +135,0 @@ return this.channels = this.channels.filter(el => el !== channel); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22622
405