Skip to content

Commit 6882c4c

Browse files
committed
refactor(welcome): update verification flow and improve message handling
- Modified the welcome message to direct users to click a link after reading the rules. - Introduced a new argument for the verification function to streamline user verification. - Refactored the private message handler to check for secret commands and verify users globally. - Enhanced user feedback for verification status and command recognition.
1 parent 62039f9 commit 6882c4c

1 file changed

Lines changed: 33 additions & 21 deletions

File tree

src/python_italy_bot/handlers/welcome.py

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def _handle_start(
123123
if rules_url:
124124
await message.reply_text(
125125
f"Per completare la verifica, leggi il regolamento:\n{rules_url}\n\n"
126-
"Dopo averlo letto, invia il comando segreto che troverai."
126+
"Dopo averlo letto, clicca sul link 'Ho letto il CoC' in fondo alla pagina."
127127
)
128128
else:
129129
captcha_content = captcha_service.get_captcha_file_content()
@@ -136,34 +136,22 @@ async def _handle_start(
136136
await message.reply_text(
137137
"Invia il comando segreto per completare la verifica."
138138
)
139+
elif args and args[0] == "CoCDoneLink":
140+
await _verify_user(user, captcha_service, context, message)
139141
else:
140142
await message.reply_text(
141143
"Ciao! Sono il bot di Python Italia.\n"
142144
"Se devi completare la verifica per un gruppo, usa il pulsante nel messaggio di benvenuto."
143145
)
144146

145147

146-
async def _handle_private_message(
147-
update: Update,
148+
async def _verify_user(
149+
user,
150+
captcha_service: CaptchaService,
148151
context: ContextTypes.DEFAULT_TYPE,
152+
message,
149153
) -> None:
150-
"""Handle private messages: check for secret command and verify user globally."""
151-
captcha_service: CaptchaService = context.bot_data["captcha_service"]
152-
message = update.message
153-
if message is None or message.text is None:
154-
return
155-
156-
user = update.effective_user
157-
if user is None:
158-
return
159-
160-
if not captcha_service.is_secret_command(message.text):
161-
await message.reply_text(
162-
"Comando non riconosciuto. Leggi il regolamento "
163-
"e invia il comando segreto che troverai."
164-
)
165-
return
166-
154+
"""Verify a user globally and unrestrict in all pending groups."""
167155
if await captcha_service.is_globally_verified(user.id):
168156
await message.reply_text(
169157
"Sei già verificato! Puoi partecipare alle discussioni in tutti i gruppi."
@@ -174,7 +162,7 @@ async def _handle_private_message(
174162
if not pending_chats:
175163
await message.reply_text(
176164
"Non hai gruppi in attesa di verifica. "
177-
"Se hai appena inviato il comando, la verifica potrebbe essere già stata applicata."
165+
"Se hai appena completato la verifica, potrebbe essere già stata applicata."
178166
)
179167
return
180168

@@ -196,3 +184,27 @@ async def _handle_private_message(
196184
"Verifica completata! Ora puoi partecipare alle discussioni "
197185
"in tutti i gruppi Python Italia."
198186
)
187+
188+
189+
async def _handle_private_message(
190+
update: Update,
191+
context: ContextTypes.DEFAULT_TYPE,
192+
) -> None:
193+
"""Handle private messages: check for secret command and verify user globally."""
194+
captcha_service: CaptchaService = context.bot_data["captcha_service"]
195+
message = update.message
196+
if message is None or message.text is None:
197+
return
198+
199+
user = update.effective_user
200+
if user is None:
201+
return
202+
203+
if not captcha_service.is_secret_command(message.text):
204+
await message.reply_text(
205+
"Comando non riconosciuto. Leggi il regolamento "
206+
"e invia il comando segreto che troverai."
207+
)
208+
return
209+
210+
await _verify_user(user, captcha_service, context, message)

0 commit comments

Comments
 (0)