Enubia/ghost-chat

support for 7TV emotes

Closed this issue · 6 comments

support for 7TV emotes to see them in the chat

That would be very nice! Currently also looking into the code tho...

That would be very nice! Currently also looking into the code tho...

It looks like the issue is that KapChat does not support 7TV, so unfortunately the devs of GhostChat cant do very much there.

Maybe im being wrong here tho...

That would be very nice! Currently also looking into the code tho...

It looks like the issue is that KapChat does not support 7TV, so unfortunately the devs of GhostChat cant do very much there.

Maybe im being wrong here tho...

you are right, it's a limitation of Kapchat

I do plan to replace it with https://www.giambaj.it/twitch/jchat/ since that has all the functionality built-in (7tv, bttv, and ffz)

will probably be done together with the redesign of the app which is currently in development

@osxzo

Actually, I did found a little workaround to add 7TV support in KapChat using the 7TV API! It was a little pain to figure out, but eventually it worked out pretty good!

I just made an override of the "loadEmotes" function in KapChat with the JavaScript inject section in the GhostChat client. Here is the code for anyone who wants to have 7TV Emotes displayed:

Chat.loadEmotes = function(callback) {
                    ['emotes/global', 'users/twitch/' + encodeURIComponent(Chat.vars.channelId)].forEach(function(endpoint) {
                        $.getJSON('https://api.betterttv.net/3/cached/' + endpoint).done(function(data) {
                            if (!Array.isArray(data)) {
                                data = data.channelEmotes.concat(data.sharedEmotes);
                            }
                            data.forEach(function(emote) {
                                Chat.vars.extraEmotes[emote.code] = {
                                    restrictions: emote.restrictions,
                                    code: emote.code,
                                    source: 'bttv',
                                    id: emote.id,
                                    '1x': Chat.BETTERTTV_EMOTE_CDN_URL_TEMPLATE.replace('{{id}}', emote.id).replace('{{image}}','1x'),
                                    '2x': Chat.BETTERTTV_EMOTE_CDN_URL_TEMPLATE.replace('{{id}}', emote.id).replace('{{image}}','2x'),
                                    '3x': Chat.BETTERTTV_EMOTE_CDN_URL_TEMPLATE.replace('{{id}}', emote.id).replace('{{image}}','3x')
                                };
                            });
                        });
                    });

                    ['emotes/global', 'users/twitch/' + encodeURIComponent(Chat.vars.channelId)].forEach(function(endpoint) {
                        $.getJSON('https://api.betterttv.net/3/cached/frankerfacez/' + endpoint).done(function(data) {
                            data.forEach(function(emote) {
                                Chat.vars.extraEmotes[emote.code] = {
                                    source: 'ffz',
                                    code: emote.code,
                                    id: emote.id,
                                    '1x': emote.images['1x'],
                                    '2x': emote.images['2x'] || emote.images['1x'],
                                    '3x': emote.images['4x'] || emote.images['2x'] || emote.images['1x']
                                };
                            });
                        });
                    });

                    ['emotes/global', 'users/twitch/' + encodeURIComponent(Chat.vars.channelId)].forEach(function(endpoint) {
                        $.getJSON('https://7tv.io/v3/users/twitch/' + encodeURIComponent(Chat.vars.channelId)).done(function(userdata) {
                            $.getJSON('https://7tv.io/v3/emote-sets/' + userdata.emote_set.id).done(function(data) {
                                
                                data.emotes.forEach(function(emote) {
                                    
                                    Chat.vars.extraEmotes[emote.name] = {
                                        source: '7tv',
                                        code: emote.name,
                                        id: emote.id,
                                        '1x': emote.data.host.url + '/' + emote.data.host.files.find(file => file.name === '1x.webp').name,
                                        '2x': emote.data.host.url + '/' + emote.data.host.files.find(file => file.name === '2x.webp').name,
                                        '3x': emote.data.host.url + '/' + emote.data.host.files.find(file => file.name === '3x.webp').name
                                    };
                                });
                            });
                        });
                    });

                    callback(true);
};

image

will be supported per default with 3.0 release