コミットを比較

...

8 コミット

作成者 SHA1 メッセージ 日付
n9k 4f34a4a0e7 v1.5.4 2022-07-17 01:12:10 +00:00
n9k e68bf56c9b Merge branch 'dev' 2022-07-17 01:11:52 +00:00
n9k 9edeea1491 Emotes: sheet filename config option 2022-07-16 23:48:46 +00:00
n9k 70036ca234 Minor formatting 2022-07-16 23:48:46 +00:00
n9k 85ccd7b96e Never gonna give broadcaster a clock captcha 2022-07-16 22:17:58 +00:00
n9k 466298696b v1.5.3 2022-07-16 22:12:28 +00:00
n9k ba5b21e5ed Merge branch 'dev' 2022-07-16 22:12:11 +00:00
n9k cadc4076c5 Bugfix: actually deverify absent users
Was using the `deverify` function which is for ratelimiting chat, so it never
did anything.
2022-07-16 22:12:04 +00:00
9個のファイルの変更19行の追加13行の削除

ファイルの表示

@ -12,7 +12,7 @@ from anonstream.utils.captcha import create_captcha_factory, create_captcha_sign
from anonstream.utils.chat import schema_to_emotes
from anonstream.utils.user import generate_blank_allowedness
__version__ = '1.5.2'
__version__ = '1.5.4'
def create_app(toml_config):
app = Quart('anonstream', static_folder=None)

ファイルの表示

@ -114,7 +114,7 @@ def add_chat_message(user, nonce, comment, ignore_empty=False):
# Deverify user every n messages
if CONFIG['CHAT_DEVERIFY_CLOCK'] is not None:
user['clock'] = (user['clock'] + 1) % CONFIG['CHAT_DEVERIFY_CLOCK']
if user['clock'] == 0:
if user['clock'] == 0 and not user['broadcaster']:
user['verified'] = False
# Notify event sockets that a chat message was added

ファイルの表示

@ -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'],
}

ファイルの表示

@ -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'],

ファイルの表示

@ -284,26 +284,26 @@ const delete_chat_messages = (seqs) => {
const hexdigest = async (string, bytelength) => {
uint8array = new TextEncoder().encode(string);
arraybuffer = await crypto.subtle.digest('sha-256', uint8array);
arraybuffer = await crypto.subtle.digest("sha-256", uint8array);
array = Array.from(new Uint8Array(arraybuffer).slice(0, bytelength));
hex = array.map(b => b.toString(16).padStart(2, '0')).join('');
hex = array.map(b => b.toString(16).padStart(2, "0")).join("");
return hex
}
const escape_css_string = (string) => {
/* https://drafts.csswg.org/cssom/#common-serializing-idioms */
const result = [];
for (const char of string) {
if (char === '\0') {
result.push('\ufffd');
} else if (char < '\u0020' || char == '\u007f') {
if (char === "\0") {
result.push("\ufffd");
} else if (char < "\u0020" || char == "\u007f") {
result.push(`\\${char.charCodeAt().toString(16)}`);
} else if (char == '"' || char == '\\') {
} else if (char == '"' || char == "\\") {
result.push(`\\${char}`);
} else {
result.push(char);
}
}
return result.join('');
return result.join("");
}
const update_emotes = async (emotes) => {
const rules = [];
@ -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

ファイルの表示

@ -66,7 +66,7 @@ async def t_sunset_users(timestamp, iteration):
# Deverify absent users
for user in get_absent_users(timestamp):
deverify(user, timestamp=timestamp)
user['verified'] = False
# Remove as many absent users as possible

ファイルの表示

@ -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;

ファイルの表示

@ -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()

ファイルの表示

@ -91,4 +91,5 @@ refresh_users = 6.0
timeout_chat = 30.0
[emote]
sheet = "emotes.png"
schema = "emotes.json"