Skip to content

Commit

Permalink
BetterTTV Emotes 3.3.20
Browse files Browse the repository at this point in the history
* Added: Emote update messages and preview when a new emote is added to the channel (or removed / updated)
  • Loading branch information
Lordmau5 committed Jan 17, 2024
1 parent 90d3b2f commit b4e0f30
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 3 deletions.
42 changes: 41 additions & 1 deletion src/ffzap-bttv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class BetterTTV extends Addon {
},
});

this.settings.add('ffzap.betterttv.update_messages', {
default: true,
ui: {
path: 'Add-Ons > BetterTTV Emotes >> Emotes > Live Emote Updates',
title: 'Show update messages',
description: 'Show messages in chat when emotes are updated in the current channel.',
component: 'setting-check-box',
}
});

this.settings.add('ffzap.betterttv.pro_badges', {
default: true,

Expand All @@ -66,7 +76,7 @@ class BetterTTV extends Addon {
description: 'Enable to show BetterTTV Pro emoticons.',
component: 'setting-check-box',
},
});
});

this.chat.context.on('changed:ffzap.betterttv.global_emoticons', this.updateEmotes, this);
this.chat.context.on('changed:ffzap.betterttv.arbitrary_emoticons', this.updateEmotes, this);
Expand Down Expand Up @@ -144,6 +154,25 @@ class BetterTTV extends Addon {
}
}

addEmoteUpdateMessage(bttvChannel, message) {
const channelId = bttvChannel.replace('twitch:', '');
const channel = this.chat.getRoom(channelId);

this.addChatNotice(channel, message);
}

addChatNotice(channel, message, tokenize = true) {
if (!channel.login) return;

if (!this.settings.get('ffzap.betterttv.update_messages')) return;

this.resolve('site.chat').addNotice(channel.login, {
message,
icon: new URL('https://betterttv.com/favicon.png'),
tokenize
});
}

getSocketEvents() {
return {
lookup_user: data => {
Expand Down Expand Up @@ -184,6 +213,7 @@ class BetterTTV extends Addon {
}
},
emote_create: ({ channel, emote: createdEmote }) => {
this.log.info(channel, createdEmote);
const emotes = this.room_emotes[channel];
if (!emotes) return;

Expand All @@ -194,14 +224,21 @@ class BetterTTV extends Addon {
emotes.push(emote);

this.emotes.addEmoteToSet(this.getChannelSetID(channel, false), emote);

this.addEmoteUpdateMessage(channel, `Added the emote ${emote.name} (${emote.name})`);
},
emote_delete: ({ channel, emoteId }) => {
const emotes = this.room_emotes[channel];
if (!emotes) return;

const existingEmote = emotes.find(e => e.id === emoteId);
if (!existingEmote) return;

this.room_emotes[channel] = emotes.filter(e => e.id !== emoteId);

this.emotes.removeEmoteFromSet(this.getChannelSetID(channel, false), emoteId);

this.addEmoteUpdateMessage(channel, `Removed the emote ${existingEmote.name}`);
},
emote_update: ({ channel, ...payload }) => {
const updatedEmote = payload.emote;
Expand All @@ -212,9 +249,12 @@ class BetterTTV extends Addon {
const emote = emotes.find(e => e.id === updatedEmote.id);
if (!emote) return;

const oldName = emote.name;
emote.name = updatedEmote.code;

this.emotes.addEmoteToSet(this.getChannelSetID(channel, false), emote);

this.addEmoteUpdateMessage(channel, `Renamed the emote ${oldName} to ${emote.name} (${emote.name})`);
}
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/ffzap-bttv/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"load_events": [
"chat-data"
],
"version": "3.3.19",
"version": "3.3.20",
"short_name": "FFZ:AP BTTV",
"name": "BetterTTV Emotes",
"author": "Lordmau5",
"description": "Adds BetterTTV Global Emotes, Channel Emotes and Pro functionality (badges and emotes).",
"website": "https://betterttv.com/",
"settings": "add_ons.better_ttv_emotes",
"created": "2019-09-12T15:31:59.000Z",
"updated": "2023-11-03T20:11:36.053Z"
"updated": "2024-01-17T20:25:24.043Z"
}

0 comments on commit b4e0f30

Please sign in to comment.