diff --git a/anonstream/config.py b/anonstream/config.py index e9f842f..023a241 100644 --- a/anonstream/config.py +++ b/anonstream/config.py @@ -169,5 +169,6 @@ def toml_to_flask_section_nojs(config): def toml_to_flask_section_emote(config): cfg = config['emote'] return { + 'EMOTE_SHEET': cfg['sheet'], 'EMOTE_SCHEMA': cfg['schema'], } diff --git a/anonstream/routes/nojs.py b/anonstream/routes/nojs.py index cf1179f..a487174 100644 --- a/anonstream/routes/nojs.py +++ b/anonstream/routes/nojs.py @@ -55,6 +55,7 @@ async def nojs_chat_messages(timestamp, user): user=user, users_by_token=USERS_BY_TOKEN, emotes=EMOTES, + emotesheet=CONFIG['EMOTE_SHEET'], emotehash=get_emotehash(tuple(EMOTES)), messages=get_scrollback(current_app.messages), timeout=CONFIG['NOJS_TIMEOUT_CHAT'], diff --git a/anonstream/static/anonstream.js b/anonstream/static/anonstream.js index 9c91adc..e8665ca 100644 --- a/anonstream/static/anonstream.js +++ b/anonstream/static/anonstream.js @@ -315,7 +315,7 @@ const update_emotes = async (emotes) => { } rules.sort(); const emotehash = await hexdigest(rules.toString(), 6); - const emotehash_rule = `.emote { background-image: url("/static/emotes.png?coords=${escape_css_string(encodeURIComponent(emotehash))}"); }`; + const emotehash_rule = `.emote { background-image: url("/static/${escape_css_string(escape(emotesheet))}?coords=${escape_css_string(encodeURIComponent(emotehash))}"); }`; const rules_set = new Set([emotehash_rule, ...rules]); const to_delete = []; @@ -337,6 +337,7 @@ let users = {}; let stats = null; let stats_received = null; let default_name = {true: "Broadcaster", false: "Anonymous"}; +let emotesheet = "emotes.png"; let max_chat_scrollback = 256; let pingpong_period = 8.0; let ping = null; @@ -734,7 +735,8 @@ const on_websocket_message = async (event) => { chat_appearance_form_name.setAttribute("placeholder", default_name[user.broadcaster]); chat_appearance_form_color.setAttribute("value", user.color); - // emote coordinates + // emotes + emotesheet = receipt.emotesheet; await update_emotes(receipt.emotes); // insert new messages diff --git a/anonstream/templates/nojs_chat_messages.html b/anonstream/templates/nojs_chat_messages.html index 43f0390..8b59731 100644 --- a/anonstream/templates/nojs_chat_messages.html +++ b/anonstream/templates/nojs_chat_messages.html @@ -134,7 +134,7 @@ line-height: 1.3125; } .emote { - background-image: url("{{ escape_css_string(url_for('static', filename='emotes.png', coords=emotehash)) | safe }}"); + background-image: url("{{ escape_css_string(url_for('static', filename=emotesheet, coords=emotehash)) | safe }}"); display: inline-block; font-size: 0; vertical-align: middle; diff --git a/anonstream/websocket.py b/anonstream/websocket.py index 66bbc11..4e5aa5e 100644 --- a/anonstream/websocket.py +++ b/anonstream/websocket.py @@ -38,6 +38,7 @@ async def websocket_outbound(queue, user): 'digest': get_random_captcha_digest_for(user), 'pingpong': CONFIG['TASK_BROADCAST_PING'], 'emotes': get_emotes_for_websocket(), + 'emotesheet': CONFIG['EMOTE_SHEET'], }) while True: payload = await queue.get() diff --git a/config.toml b/config.toml index e727d6d..076ddef 100644 --- a/config.toml +++ b/config.toml @@ -91,4 +91,5 @@ refresh_users = 6.0 timeout_chat = 30.0 [emote] +sheet = "emotes.png" schema = "emotes.json"