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

simple channel redemption display in chat, display cheer text in chat #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
32 changes: 28 additions & 4 deletions chat.html
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,7 @@
Highlight: Symbol('Highlight'),
//Mention: Symbol('Mention'), // TODO: Might be worth implementing this?
Announcement: Symbol('Announcement'),
Redemption: Symbol('Redemption')
};

let add_message = (id, message, author, color, timestamp, badges = [], highlight = Highlights.None) => {
Expand Down Expand Up @@ -839,7 +840,15 @@
}

// Adds the user line and message to the message div
div_message.appendChild(el_user);
if (highlight !== Highlights.Redemption) {
div_message.appendChild(el_user);
} else {
el_message.style.color = get_color_hex({
r: 'ad',
g: 'ad',
b: 'b8'
});
}
div_message.appendChild(el_message);

document.getElementById('chat').appendChild(div_message);
Expand Down Expand Up @@ -1185,7 +1194,9 @@
"Announcement",
"UserTimedOut",
"UserBanned",
"ChatMessageDeleted"
"ChatMessageDeleted",
"RewardRedemption",
"Cheer"
];
}

Expand Down Expand Up @@ -1239,6 +1250,14 @@
m.color, m.message, m.emotes, m.role, m.badges,
m.isHighlighted ? Highlights.Highlight : Highlights.None);

} else if (wsdata.event.type === 'Cheer') {
let m = wsdata.data.message;

// Add m.cheerEmotes and replace Cheers with cheerEmotes in add_message
StreamerBot['message']['twitch'](m.msgId, m.userId, m.displayName,
m.color, m.message, m.emotes, m.role, m.badges,
m.isHighlighted ? Highlights.Highlight : Highlights.None);

} else if (wsdata.event.type === 'Announcement') {
if (config["ui"]["announcements"] === false) {
return;
Expand Down Expand Up @@ -1275,6 +1294,11 @@
} else if (wsdata.event.type === 'ChatMessageDeleted') {
console.debug(['Message deleted', wsdata]);
remove_messages_by_message_id(wsdata.data.targetMessageId);
} else if (wsdata.event.type === 'RewardRedemption') {
let m = wsdata.data;

StreamerBot['message']['twitch'](m.id, m.user_id, m.user_name, "#adadb8",
`| ${m.user_name} redeemed ${m.reward.title} - ${m.reward.cost}`, [], 1, [], Highlights.Redemption);
} else {
console.warn(['Twitch Event not implemented', event]);
}
Expand Down Expand Up @@ -1604,7 +1628,7 @@
} else {
initializeConnections();
}

if (config["version"]["check"] === true && config["debug"] === false) {
version_check().then(version => {
let version_el = document.getElementById("version-notice");
Expand Down Expand Up @@ -1638,4 +1662,4 @@
</script>
</body>

</html>
</html>