Skip to content

Commit b7fb162

Browse files
committed
Updated time command: fixed unit handling
1 parent c8f7c2b commit b7fb162

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/join_captcha_bot.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2370,13 +2370,28 @@ async def cmd_time(update: Update, context: ContextTypes.DEFAULT_TYPE):
23702370
bot, chat_type, chat_id, TEXT[lang]["TIME_NOT_NUM"],
23712371
topic_id=tlg_get_msg_topic(update_msg))
23722372
return
2373-
# Get time arguments
2373+
# Require user to provide unit
2374+
if len(args) < 2:
2375+
await tlg_send_msg_type_chat(
2376+
bot, chat_type, chat_id,
2377+
"""⚠️ Please specify unit.
2378+
Usage:
2379+
Seconds:
2380+
/time <value> sec
2381+
or /time <value> secs
2382+
or /time <value> seconds
2383+
or /time <value> s
2384+
Minutes:
2385+
/time <value> min
2386+
or /time <value> mins
2387+
or /time <value> minutes
2388+
or /time <value> m""",
2389+
topic_id=tlg_get_msg_topic(update_msg))
2390+
return
2391+
# Get time value and unit
23742392
new_time = int(args[0])
2375-
min_sec = "min"
2376-
if len(args) > 1:
2377-
min_sec = args[1].lower()
2378-
# Check if time format is not minutes or seconds
2379-
# Convert time value to seconds if min format
2393+
min_sec = args[1].lower()
2394+
# Validate and convert
23802395
if min_sec in ["m", "min", "mins", "minutes"]:
23812396
min_sec = "min"
23822397
new_time_str = f"{new_time} min"

0 commit comments

Comments
 (0)