From c1e3137a7841ff483c0a93959f167a4aaf78c072 Mon Sep 17 00:00:00 2001 From: Linus E <75929322+Rripped@users.noreply.github.com> Date: Mon, 16 May 2022 18:27:02 +0200 Subject: [PATCH] changed regex --- source/bot.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/bot.py b/source/bot.py index e8c080a..3224e41 100644 --- a/source/bot.py +++ b/source/bot.py @@ -87,8 +87,8 @@ def start_name_setter(message): if str(message.text).lower() == "cancel": # Set user name to user user_name = "User" + str(user_id) # generate user name, user can change it with /changename - if not re.match(r'^[a-zA-Z][a-zA-Z0-9_\-]+$', str(message.text)): # regex pattern for username: has to start with a letter, can contain letters, numbers, underscore and hyphen - bot.reply_to(message, "Name has to be alphanumeric (including underscores) and start with a letter") + if not re.match(r'^[a-zA-Z][a-zA-Z0-9\-]+$', str(message.text)): # regex pattern for username: has to start with a letter, can contain letters, numbers and hyphen + bot.reply_to(message, "Name has to be alphanumeric (including -) and start with a letter") return user_name = str(message.text) @@ -483,8 +483,8 @@ def change_name_setter(message): bot.reply_to(message, "Name not changed") return - if not re.match(r'^[a-zA-Z][a-zA-Z0-9_\-]+$', str(message.text)): # same pattern as in /start - bot.reply_to(message, "Name has to be alphanumeric (including underscores) and start with a letter") + if not re.match(r'^[a-zA-Z][a-zA-Z0-9\-]+$', str(message.text)): # same pattern as in /start + bot.reply_to(message, "Name has to be alphanumeric (including -) and start with a letter") return else: