2022-02-17 09:20:51 +09:00
|
|
|
import base64
|
|
|
|
import hashlib
|
|
|
|
import secrets
|
|
|
|
from collections import OrderedDict
|
|
|
|
from math import inf
|
|
|
|
|
2022-02-17 21:51:09 +09:00
|
|
|
from quart import escape, Markup
|
|
|
|
|
2022-02-17 09:20:51 +09:00
|
|
|
def generate_token():
|
|
|
|
return secrets.token_hex(16)
|
|
|
|
|
2022-02-20 16:20:43 +09:00
|
|
|
def get_user_for_websocket(user):
|
2022-02-22 18:30:23 +09:00
|
|
|
keys = ['broadcaster', 'name', 'color', 'tripcode', 'tag']
|
2022-02-17 09:20:51 +09:00
|
|
|
return {key: user[key] for key in keys}
|
2022-02-17 21:51:09 +09:00
|
|
|
|
|
|
|
def concatenate_for_notice(string, *tuples):
|
|
|
|
if not tuples:
|
|
|
|
return string
|
|
|
|
markup = Markup(
|
|
|
|
''.join(
|
|
|
|
f' <mark>{escape(x)}</mark>{escape(y)}'
|
|
|
|
for x, y in tuples
|
|
|
|
)
|
|
|
|
)
|
|
|
|
return string + markup
|