コミットを比較
3 コミット
a30b485b43
...
022bebed73
作成者 | SHA1 | 日付 |
---|---|---|
n9k | 022bebed73 | |
n9k | a97f3254bd | |
n9k | ea2a194c93 |
|
@ -13,7 +13,7 @@ from anonstream.quart import Quart
|
|||
from anonstream.utils.captcha import create_captcha_factory, create_captcha_signer
|
||||
from anonstream.utils.user import generate_blank_allowedness
|
||||
|
||||
__version__ = '1.6.7'
|
||||
__version__ = '1.6.8'
|
||||
|
||||
def create_app(toml_config):
|
||||
app = Quart('anonstream', static_folder=None)
|
||||
|
|
|
@ -10,6 +10,7 @@ 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
|
||||
from anonstream.control.spec.methods.title import SPEC as SPEC_TITLE
|
||||
from anonstream.control.spec.methods.tripcode import SPEC as SPEC_TRIPCODE
|
||||
from anonstream.control.spec.methods.user import SPEC as SPEC_USER
|
||||
|
||||
SPEC = Str({
|
||||
|
@ -21,6 +22,7 @@ SPEC = Str({
|
|||
'allowednesss': SPEC_ALLOWEDNESS,
|
||||
'emote': SPEC_EMOTE,
|
||||
'config': SPEC_CONFIG,
|
||||
'tripcode': SPEC_TRIPCODE,
|
||||
})
|
||||
|
||||
async def parse(request):
|
||||
|
|
|
@ -29,6 +29,7 @@ async def cmd_help():
|
|||
' emote show.....................show all current emotes\n'
|
||||
' emote reload...................try reloading the emote schema\n'
|
||||
' config show OPTION.............show app config option\n'
|
||||
' tripcode generate PASSWORD.....show tripcode for given password\n'
|
||||
)
|
||||
return normal, response
|
||||
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
# 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, ArgsJsonString
|
||||
from anonstream.control.spec.utils import json_dumps_contiguous
|
||||
from anonstream.helpers.tripcode import generate_tripcode
|
||||
|
||||
CONFIG = current_app.config
|
||||
|
||||
async def cmd_tripcode_help():
|
||||
normal = ['tripcode', 'help']
|
||||
response = (
|
||||
'Usage: tripcode generate PASSWORD\n'
|
||||
'Commands:\n'
|
||||
' tripcode generate PASSWORD....show tripcode for given password\n'
|
||||
'Definitions:\n'
|
||||
' PASSWORD................json string, max length in config.toml (`chat.max_tripcode_password_length`)\n'
|
||||
)
|
||||
return normal, response
|
||||
|
||||
async def cmd_tripcode_generate(password):
|
||||
if len(password) > CONFIG['CHAT_TRIPCODE_PASSWORD_MAX_LENGTH']:
|
||||
raise CommandFailed(
|
||||
f'password exceeded maximum configured length of '
|
||||
f'{CONFIG["CHAT_TRIPCODE_PASSWORD_MAX_LENGTH"]} '
|
||||
f'characters'
|
||||
)
|
||||
tripcode = generate_tripcode(password)
|
||||
normal = ['tripcode', 'generate', json_dumps_contiguous(password)]
|
||||
response = json.dumps(tripcode) + '\n'
|
||||
return normal, response
|
||||
|
||||
SPEC = Str({
|
||||
None: End(cmd_tripcode_help),
|
||||
'help': End(cmd_tripcode_help),
|
||||
'generate': ArgsJsonString(End(cmd_tripcode_generate)),
|
||||
})
|
読み込み中…
新しいイシューから参照