A floating-point bid option is now available.
This commit is contained in:
@@ -15,6 +15,34 @@ logger = logging.getLogger("main_settings")
|
||||
router_main_settings = Router()
|
||||
|
||||
|
||||
def is_number(value: str) -> bool:
|
||||
"""
|
||||
Checks if a given string represents a number.
|
||||
|
||||
Args:
|
||||
value (str): The string to check.
|
||||
|
||||
Returns:
|
||||
bool: True if the string represents a number, False otherwise.
|
||||
"""
|
||||
try:
|
||||
# Convert the string to a float
|
||||
num = float(value)
|
||||
# Check if the number is positive
|
||||
if num <= 0:
|
||||
return False
|
||||
# Check if the string contains "+" or "-"
|
||||
if "+" in value or "-" in value:
|
||||
return False
|
||||
# Check if the string contains only digits
|
||||
allowed_chars = set("0123456789.")
|
||||
if not all(ch in allowed_chars for ch in value):
|
||||
return False
|
||||
return True
|
||||
except ValueError:
|
||||
return False
|
||||
|
||||
|
||||
async def reg_new_user_default_main_settings(id, message):
|
||||
tg_id = id
|
||||
|
||||
@@ -124,7 +152,6 @@ async def state_trading_mode(callback: CallbackQuery, state):
|
||||
logger.error("Ошибка при обновлении режима торговли: %s", e)
|
||||
|
||||
|
||||
|
||||
async def switch_mode_enabled_message(message, state):
|
||||
await state.set_state(update_main_settings.switch_mode_enabled)
|
||||
|
||||
@@ -304,7 +331,7 @@ async def state_starting_quantity(message: Message, state):
|
||||
data = await state.get_data()
|
||||
data_settings = await rq.get_user_main_settings(message.from_user.id)
|
||||
|
||||
if data['starting_quantity'].isdigit():
|
||||
if is_number(data['starting_quantity']):
|
||||
await message.answer(f"✅ Изменено: {data_settings['starting_quantity']} → {data['starting_quantity']}")
|
||||
|
||||
await rq.update_starting_quantity(message.from_user.id, data['starting_quantity'])
|
||||
|
Reference in New Issue
Block a user