Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added debug mode for loading channels that have never been registered at emote providers #6

Merged
merged 1 commit into from
Aug 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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