-
Notifications
You must be signed in to change notification settings - Fork 25
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
Support displaying pronouns from Alejo's Twitch Chat Pronouns API #157
base: main
Are you sure you want to change the base?
Conversation
@@ -37,6 +37,7 @@ | |||
<!-- <script src="/scripts/bttvIntegration.mjs" type="module"></script> --> | |||
<script src="/scripts/color.mjs" type="module"></script> | |||
<script src="/scripts/handleChat.mjs" type="module"></script> | |||
<script src="/scripts/pronouns.mjs" type="module"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should scripts in this block that are unused unless a specific query parameter is set be loaded on every request?
Same treatment as the demo
script, maybe?
{% if eleventy.serverless.query.DEMO %}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the difference here is that the main script imports these modules, and I'm not sure there's a way to do that safely without guaranteeing those modules are there? Worth experimenting with, for sure, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put a throw new Error()
in the getPronouns
function and the demo stopped working.
So I handled possible errors with a .catch clause.
Feel free to handle differently.
@@ -107,6 +158,7 @@ const MOCK_COMFY = (function () { | |||
}; | |||
|
|||
const allUsers = [broadcaster, ...mods, broadcaster, ...viewers, broadcaster]; | |||
USERS = [broadcaster, ...mods, ...viewers]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for these 2 arrays?
Can the first one be reused? (setting let allUser = [];
at the top of the file and assigning it here).
Why is broadcaster
used three times in the allUser
array?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great question - agreed that the duplication is kind of confusing. The reason allUsers
has several broadcaster
instances is so that the whole array can be weighted to pick the broadcaster three times more often than any of the fake mods/viewers. However, I think we could achieve a similar-ish effect by just generating fewer fake mods/viewers — which might be worth it anyways. I'm no sure demo really needs 20 "chatters."
@@ -142,6 +194,7 @@ const MOCK_COMFY = (function () { | |||
Init(__username, __auth, channelNames) { | |||
if (channelNames.length) { | |||
broadcaster.user = channelNames[0]; | |||
BROADCASTER_NAME = broadcaster.user; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question.
Can the already existing broadcaster
be reused instead of this extra variable?
By lifting that variable creation outside of the COMFY_MOCK
and reusing it inside.
Alejo's Twitch Chat Pronouns service allows folks to authenticate with their Twitch accounts and set their pronouns. Anyone viewing a Twitch chat with the service's browser extension can see the pronouns alongside chatters' usernames if set. Pronouns are exposed via an API, which Alejo has specified in his server that he is comfortable with projects such as chat overlays so long as results are cached for "at least 10 to 15 minutes."
This pull request introduces a
showPronouns
overlay configuration query parameter which, when enabled, queries Alejo's service and displays pronouns alongside the sender's username. Additionally, the message list item will be given adata-twitch-sender-pronouns
attribute with the pronouns, to enable pronoun-specific styling within themes. If the user has not set their pronouns, no pronouns will be displayed for them. If someone sends a message at least 15 minutes after their first message while the overlay's active, the overlay will revalidate and update the cache if necessary.If the pronoun service is down, the overlay should (🤞🏻) handle it gracefully and simply not display the pronoun.