From 4020faec1397cb381f8787198436e6912178dab6 Mon Sep 17 00:00:00 2001 From: dbroqua Date: Fri, 24 Jan 2020 09:09:32 +0100 Subject: [PATCH] Fixed bug on undefined title/artist --- index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9761095..e446765 100644 --- a/index.js +++ b/index.js @@ -96,8 +96,7 @@ if (!process.env.STREAM_TYPE || process.env.STREAM_TYPE === 'radio') { request({ method: 'GET', url: process.env.STREAM_URL - }, - (error, response, body) => { + }, (error, response, body) => { if (!error && response.statusCode === 200) { try { const res = JSON.parse(process.env.STREAM_PARSE ? body.replace('updateFromMediaItem(', '').replace(');', '') : body) @@ -138,7 +137,7 @@ if (!process.env.STREAM_TYPE || process.env.STREAM_TYPE === 'radio') { break } - if (previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) { + if (currentSong.title && currentSong.artist && previousSong.title !== currentSong.title && previousSong.artist !== currentSong.artist) { checkCurrentSong() } } catch (e) { @@ -301,7 +300,7 @@ bot.addListener('pm', function (from, to, message) { // Say hello! if (process.env.SAY_HELLO && process.env.SAY_HELLO === 'true') { bot.addListener('join', (channel, who) => { - // Welcome them in! + // Welcome them in! if (who !== process.env.IRC_NICKNAME) { botSay(process.env.IRC_CHANNEL, 'Hello ' + who + '! Have a metal day! \\m/(-.-)\\m/', true, true) }