Make sure emotes use correct hash

This commit is contained in:
Zack Rauen 2020-07-30 15:39:03 -04:00
parent d85f455a0d
commit c687b97d66
2 changed files with 20 additions and 22 deletions

View File

@ -1,5 +1,4 @@
{
"blacklist": [
[
"8Bit",
"AAAAAH",
"AESTHETIC",
@ -1368,5 +1367,4 @@
"vogel",
"xDDDD",
"yukon"
]
}
]

View File

@ -23,31 +23,31 @@ EmoteModule.prototype.init = async function () {
const emoteInfo = {
TwitchGlobal: {
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotedata_twitch_global.json`,
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotedata_twitch_global.json`,
variable: "TwitchGlobal",
oldVariable: "emotesTwitch",
getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`
},
TwitchSubscriber: {
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotedata_twitch_subscriber.json`,
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotedata_twitch_subscriber.json`,
variable: "TwitchSubscriber",
oldVariable: "subEmotesTwitch",
getEmoteURL: (e) => `https://static-cdn.jtvnw.net/emoticons/v1/${e}/1.0`
},
FrankerFaceZ: {
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotedata_ffz.json`,
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotedata_ffz.json`,
variable: "FrankerFaceZ",
oldVariable: "emotesFfz",
getEmoteURL: (e) => `https://cdn.frankerfacez.com/emoticon/${e}/1`
},
BTTV: {
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotedata_bttv.json`,
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotedata_bttv.json`,
variable: "BTTV",
oldVariable: "emotesBTTV",
getEmoteURL: (e) => `https://cdn.betterttv.net/emote/${e}/1x`
},
BTTV2: {
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotedata_bttv2.json`,
url: `https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotedata_bttv2.json`,
variable: "BTTV2",
oldVariable: "emotesBTTV2",
getEmoteURL: (e) => `https://cdn.betterttv.net/emote/${e}/1x`
@ -56,7 +56,7 @@ EmoteModule.prototype.init = async function () {
if (bdConfig.local) return;
await this.getBlacklist();
await this.getBlockedEmotes();
await this.loadEmoteData(emoteInfo);
while (!BDV2.MessageComponent) await new Promise(resolve => setTimeout(resolve, 100));
@ -198,8 +198,13 @@ EmoteModule.prototype.loadEmoteData = async function(emoteInfo) {
for (const e in emoteInfo) {
await new Promise(r => setTimeout(r, 1000));
const data = await this.downloadEmotes(emoteInfo[e]);
bdEmotes[emoteInfo[e].variable] = data;
try {
const data = await this.downloadEmotes(emoteInfo[e]);
bdEmotes[emoteInfo[e].variable] = data;
}
catch (err) {
bdEmotes[emoteInfo[e].variable] = {};
}
}
if (settingsCookie["fork-ps-2"]) Utils.showToast("All emotes successfully downloaded.", {type: "success"});
@ -209,10 +214,11 @@ EmoteModule.prototype.loadEmoteData = async function(emoteInfo) {
};
EmoteModule.prototype.downloadEmotes = function(emoteMeta) {
emoteMeta.url = Utils.formatString(emoteMeta.url, {hash: bdConfig.hash});
const request = require("request");
const options = {
url: emoteMeta.url,
timeout: emoteMeta.timeout ? emoteMeta.timeout : 5000,
timeout: emoteMeta.timeout ? emoteMeta.timeout : 12000,
json: true
};
@ -222,12 +228,6 @@ EmoteModule.prototype.downloadEmotes = function(emoteMeta) {
request(options, (error, response, parsedData) => {
if (error) {
Utils.err("Emotes", "Could not download " + emoteMeta.variable, error);
if (emoteMeta.backup) {
emoteMeta.url = emoteMeta.backup;
emoteMeta.backup = null;
if (emoteMeta.backupParser) emoteMeta.parser = emoteMeta.backupParser;
return resolve(this.downloadEmotes(emoteMeta));
}
return reject({});
}
@ -246,11 +246,11 @@ EmoteModule.prototype.downloadEmotes = function(emoteMeta) {
});
};
EmoteModule.prototype.getBlacklist = function () {
EmoteModule.prototype.getBlockedEmotes = function () {
return new Promise(resolve => {
require("request").get({url: "https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/${bdConfig.hash}/assets/emotefilter.json", json: true}, function (err, resp, data) {
require("request").get({url: Utils.formatString("https://cdn.staticaly.com/gh/rauenzi/BetterDiscordApp/{{hash}}/assets/emotefilter.json", {hash: bdConfig.hash}), json: true}, function (err, resp, data) {
if (err) return resolve(bemotes);
resolve(bemotes.splice(0, 0, ...data.blacklist));
resolve(bemotes.splice(0, 0, ...data));
});
});
};