コミットを比較
2 コミット
7fb8418018
...
1daefdbef6
作成者 | SHA1 | 日付 |
---|---|---|
n9k | 1daefdbef6 | |
n9k | 4c2d42bed4 |
|
@ -11,7 +11,6 @@ from anonstream.config import update_flask_from_toml
|
|||
from anonstream.emote import load_emote_schema
|
||||
from anonstream.quart import Quart
|
||||
from anonstream.utils.captcha import create_captcha_factory, create_captcha_signer
|
||||
from anonstream.utils.chat import precompute_emote_regex
|
||||
from anonstream.utils.user import generate_blank_allowedness
|
||||
|
||||
__version__ = '1.6.4'
|
||||
|
|
|
@ -8,7 +8,8 @@ from quart import current_app, escape
|
|||
|
||||
from anonstream.broadcast import broadcast, broadcast_users_update
|
||||
from anonstream.events import notify_event_sockets
|
||||
from anonstream.helpers.chat import generate_nonce_hash, get_scrollback, insert_emotes
|
||||
from anonstream.helpers.chat import generate_nonce_hash, get_scrollback
|
||||
from anonstream.helpers.emote import insert_emotes
|
||||
from anonstream.utils.chat import get_message_for_websocket, get_approx_linespan
|
||||
|
||||
CONFIG = current_app.config
|
||||
|
|
|
@ -5,6 +5,7 @@ from anonstream.control.spec import ParseException, Parsed
|
|||
from anonstream.control.spec.common import Str
|
||||
from anonstream.control.spec.methods.allowedness import SPEC as SPEC_ALLOWEDNESS
|
||||
from anonstream.control.spec.methods.chat import SPEC as SPEC_CHAT
|
||||
from anonstream.control.spec.methods.emote import SPEC as SPEC_EMOTE
|
||||
from anonstream.control.spec.methods.exit import SPEC as SPEC_EXIT
|
||||
from anonstream.control.spec.methods.help import SPEC as SPEC_HELP
|
||||
from anonstream.control.spec.methods.title import SPEC as SPEC_TITLE
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# SPDX-FileCopyrightText: 2022 n9k <https://git.076.ne.jp/ninya9k>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
from quart import current_app
|
||||
|
||||
from anonstream.emote import load_emote_schema, BadEmoteName
|
||||
from anonstream.control.spec.common import Str, End
|
||||
from anonstream.control.exceptions import CommandFailed
|
||||
|
||||
CONFIG = current_app.config
|
||||
|
||||
async def cmd_emote_help():
|
||||
normal = ['emote', 'help']
|
||||
response = (
|
||||
'Usage: emote\n'
|
||||
'Commands:\n'
|
||||
' emote reload......try to reload the emote schema (existing messages are not modified)\n'
|
||||
)
|
||||
return normal, response
|
||||
|
||||
async def cmd_emote_reload():
|
||||
try:
|
||||
emotes = load_emote_schema(app.config['EMOTE_SCHEMA'])
|
||||
except BadEmoteName as e:
|
||||
error, *_ = e.args
|
||||
raise CommandFailed(error) from e
|
||||
normal = ['emote', 'reload']
|
||||
response = ''
|
||||
return normal, response
|
||||
|
||||
SPEC = Str({
|
||||
None: End(cmd_emote_help),
|
||||
'help': End(cmd_emote_help),
|
||||
'reload': End(cmd_emote_reload),
|
||||
})
|
||||
|
|
@ -1,10 +1,12 @@
|
|||
import json
|
||||
import re
|
||||
|
||||
from quart import escape
|
||||
|
||||
class BadEmoteName(Exception):
|
||||
pass
|
||||
|
||||
def load_emote_schema(filepath)
|
||||
def load_emote_schema(filepath):
|
||||
with open(filepath) as fp:
|
||||
emotes = json.load(fp)
|
||||
precompute_emote_regex(emotes)
|
||||
|
@ -19,7 +21,7 @@ def precompute_emote_regex(schema):
|
|||
f'whitespace is not allowed in emote names: {emote["name"]!r}'
|
||||
)
|
||||
for length in (emote['width'], emote['height']):
|
||||
if length is not None or isinstance(length, int) and length >= 0:
|
||||
if length is not None and (not isinstance(length, int) or length < 0):
|
||||
raise BadEmoteName(
|
||||
f'emote dimensions must be null or non-negative integers: '
|
||||
f'{emote["name"]!r}'
|
||||
|
|
読み込み中…
新しいイシューから参照