Skip to content

Commit

Permalink
Merge pull request #6 from timbohlmann/debug-mode
Browse files Browse the repository at this point in the history
Added debug mode for loading channels that have never been registered at emote providers
  • Loading branch information
smilefx authored Aug 26, 2022
2 parents c357223 + 6c1a5a9 commit 7a98d95
Showing 1 changed file with 90 additions and 48 deletions.
138 changes: 90 additions & 48 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ const EventEmitter = require('events');

class ParseEmitter extends EventEmitter {}

var debug = true;

var loadedAssets = {};

function loadAssets(channel, args) {
Expand Down Expand Up @@ -37,10 +39,13 @@ function loadAssets(channel, args) {
var uid = body.data[0].id;

} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load user information for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load user information for " + channel
});
}

} finally {
loadedAssets[channel].uid = uid;
loadConcurrent(uid, channel, args);
Expand Down Expand Up @@ -82,10 +87,13 @@ function loadConcurrent(uid, channel, args) {
}

} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load FFZ channel emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load FFZ channel emotes for " + channel
});
}

}
});
} else {
Expand Down Expand Up @@ -121,10 +129,13 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load FFZ global emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load FFZ global emotes for " + channel
});
}

}

});
Expand Down Expand Up @@ -164,10 +175,13 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load BetterTTV channel emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load BetterTTV channel emotes for " + channel
});
}

}
});
} else {
Expand Down Expand Up @@ -198,10 +212,13 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load BetterTTV global emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load BetterTTV global emotes for " + channel
});
}

}
});
} else {
Expand Down Expand Up @@ -242,18 +259,24 @@ function loadConcurrent(uid, channel, args) {
}
}
} else {
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
}


checkLoadedAll(channel, "7tv", "channel", true, args);
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
}

}
});
} else {
Expand Down Expand Up @@ -285,29 +308,38 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV channel emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV channel emotes for " + channel
});
}

}
});
} else {
checkLoadedAll(channel, "7tv", "global", null, args);
}
} else {
exports.events.emit('error', {
channel: channel,
error: "No 7TV user available for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "No 7TV user available for " + channel
});
}


checkLoadedAll(channel, "7tv", "channel", true, args);
checkLoadedAll(channel, "7tv", "global", true, args);
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load 7TV global emotes for " + channel
});
}

}
});
} else {
Expand Down Expand Up @@ -344,10 +376,13 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load global badges for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load global badges for " + channel
});
}

}
});

Expand Down Expand Up @@ -377,10 +412,13 @@ function loadConcurrent(uid, channel, args) {
}
}
} catch (error) {
exports.events.emit('error', {
channel: channel,
error: "Failed to load channel badges for " + channel
});
if(debug){
exports.events.emit('error', {
channel: channel,
error: "Failed to load channel badges for " + channel
});
}

}
});
}
Expand Down Expand Up @@ -723,6 +761,10 @@ function loadOptions(args) {
return args;
}

exports.setDebug = function(value){
debug = value;
}

exports.loadAssets = function (channel, args) {
args = loadOptions(args);
loadAssets(channel.replace("#", "").trim().toLowerCase(), args);
Expand Down

0 comments on commit 7a98d95

Please sign in to comment.