Control socket: show app.config options
このコミットが含まれているのは:
コミット
26a86fac7a
|
@ -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.config import SPEC as SPEC_CONFIG
|
||||
from anonstream.control.spec.methods.emote import SPEC as SPEC_EMOTE
|
||||
from anonstream.control.spec.methods.help import SPEC as SPEC_HELP
|
||||
from anonstream.control.spec.methods.quit import SPEC as SPEC_QUIT
|
||||
|
@ -19,6 +20,7 @@ SPEC = Str({
|
|||
'user': SPEC_USER,
|
||||
'allowednesss': SPEC_ALLOWEDNESS,
|
||||
'emote': SPEC_EMOTE,
|
||||
'config': SPEC_CONFIG,
|
||||
})
|
||||
|
||||
async def parse(request):
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
# SPDX-FileCopyrightText: 2022 n9k <https://git.076.ne.jp/ninya9k>
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
import json
|
||||
|
||||
from quart import current_app
|
||||
|
||||
from anonstream.control.exceptions import CommandFailed
|
||||
from anonstream.control.spec.common import Str, End, ArgsString
|
||||
|
||||
CONFIG = current_app.config
|
||||
|
||||
async def cmd_config_help():
|
||||
normal = ['config', 'help']
|
||||
response = (
|
||||
'Usage: config show OPTION\n'
|
||||
'Commands:\n'
|
||||
' config show OPTION....show entry in app.config\n'
|
||||
'Definitions:\n'
|
||||
' OPTION................app.config key, re:[A-Z0-9_]+\n'
|
||||
)
|
||||
return normal, response
|
||||
|
||||
async def cmd_config_show(option):
|
||||
if option in {'SECRET_KEY', 'SECRET_KEY_STRING'}:
|
||||
raise CommandFailed('not going to show our secret key')
|
||||
try:
|
||||
value = CONFIG[option]
|
||||
except KeyError:
|
||||
raise CommandFailed(f'no config option with key {option!r}')
|
||||
try:
|
||||
value_json = json.dumps(value)
|
||||
except (TypeError, ValueError):
|
||||
raise CommandFailed(f'value is not json serializable')
|
||||
normal = ['config', 'show']
|
||||
response = value_json + '\n'
|
||||
return normal, response
|
||||
|
||||
SPEC = Str({
|
||||
None: End(cmd_config_help),
|
||||
'help': End(cmd_config_help),
|
||||
'show': ArgsString(End(cmd_config_show)),
|
||||
})
|
|
@ -28,6 +28,7 @@ async def cmd_help():
|
|||
' allowedness remove SET STRING..remove from the blacklist/whitelist\n'
|
||||
' emote show.....................show all current emotes\n'
|
||||
' emote reload...................try reloading the emote schema\n'
|
||||
' config show OPTION.............show app config option\n'
|
||||
)
|
||||
return normal, response
|
||||
|
||||
|
|
読み込み中…
新しいイシューから参照