mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[redbot.setup] Ask for confirmation when passed instance name contains hyphens + allow to use dots (#3920)
* Change regex and the error message * few changes see ^^^ GH comment if it doesn't pass the RegEx `[a-zA-Z0-9_\.]*` then: - if on Linux and contains a "-" anywhere, not allowed - if it contains a space or starts with a "-", not allowed - if the top two don't trigger, then `confirm()` with the user. * black why * 3.3.9 * fk * ty aika * review :aha: * oopsie Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * this is just vexed tries and jack fixes Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> * quite sad really Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com> Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
parent
144b7b36d0
commit
4c62c67fd4
@ -12,6 +12,7 @@ from typing import Dict, Any, Optional, Union
|
||||
import appdirs
|
||||
import click
|
||||
|
||||
from redbot.core.cli import confirm
|
||||
from redbot.core.utils._internal_utils import safe_delete, create_backup as red_create_backup
|
||||
from redbot.core import config, data_manager, drivers
|
||||
from redbot.core.drivers import BackendType, IdentifierData
|
||||
@ -128,16 +129,23 @@ def get_name() -> str:
|
||||
print(
|
||||
"Please enter a name for your instance,"
|
||||
" it will be used to run your bot from here on out.\n"
|
||||
"This name is case-sensitive and can only include characters"
|
||||
" A-z, numbers, underscores, and hyphens."
|
||||
"This name is case-sensitive and should only include characters"
|
||||
" A-z, numbers, underscores (_) and periods (.)."
|
||||
)
|
||||
name = input("> ")
|
||||
if re.fullmatch(r"[a-zA-Z0-9_\-]*", name) is None:
|
||||
if re.fullmatch(r"[A-Za-z0-9_\.\-]*", name) is None:
|
||||
print(
|
||||
"ERROR: Instance name can only include"
|
||||
" characters A-z, numbers, underscores, and hyphens!"
|
||||
"ERROR: Instance names can only include characters A-z, numbers, "
|
||||
"underscores (_) and periods (.)."
|
||||
)
|
||||
name = ""
|
||||
elif "-" in name and not confirm(
|
||||
"Hyphens (-) in instance names may cause issues. Are you sure you want to continue with this instance name?",
|
||||
default=False,
|
||||
):
|
||||
name = ""
|
||||
|
||||
print() # new line for aesthetics
|
||||
return name
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user