Make Gender Input Case-Insensitive in `conversationbot.py` (#4855)

This commit is contained in:
Xiaohu
2025-07-15 23:00:54 +08:00
committed by GitHub
parent 957345f6d9
commit e9dd490b2c
2 changed files with 8 additions and 1 deletions
@@ -0,0 +1,5 @@
other= "Make Gender Input Case-Insensitive in ``conversationbot.py``"
[[pull_requests]]
uid = "4855"
author_uid = "fengxiaohu"
closes_threads = ["4846"]
+3 -1
View File
@@ -145,7 +145,9 @@ def main() -> None:
conv_handler = ConversationHandler(
entry_points=[CommandHandler("start", start)],
states={
GENDER: [MessageHandler(filters.Regex("^(Boy|Girl|Other)$"), gender)],
# Use case-insensitive regex to accept gender input regardless of letter casing,
# e.g., "boy", "BOY", "Girl", etc., will all be matched
GENDER: [MessageHandler(filters.Regex("(?i)^(Boy|Girl|Other)$"), gender)],
PHOTO: [MessageHandler(filters.PHOTO, photo), CommandHandler("skip", skip_photo)],
LOCATION: [
MessageHandler(filters.LOCATION, location),