Add examples on edit fail
This commit is contained in:
parent
346a622ab5
commit
4f9841cc16
3 changed files with 11 additions and 2 deletions
|
@ -11,6 +11,7 @@ def data(update: Update, context: CallbackContext):
|
||||||
u = db.User(update["_effective_user"]["id"])
|
u = db.User(update["_effective_user"]["id"])
|
||||||
s.add(u)
|
s.add(u)
|
||||||
s.commit()
|
s.commit()
|
||||||
|
u = s.query(db.User).get(update["_effective_user"]["id"])
|
||||||
s.close()
|
s.close()
|
||||||
context.bot.send_message(chat_id=update.effective_chat.id,
|
context.bot.send_message(chat_id=update.effective_chat.id,
|
||||||
text=f"*Firstname*: `{u.first_name}`\n"
|
text=f"*Firstname*: `{u.first_name}`\n"
|
||||||
|
|
|
@ -17,6 +17,14 @@ rex = {
|
||||||
"address": address_re
|
"address": address_re
|
||||||
}
|
}
|
||||||
|
|
||||||
|
examples = {
|
||||||
|
"first_name": "Camille",
|
||||||
|
"last_name": "Dupont",
|
||||||
|
"birth_date": "01/01/1970",
|
||||||
|
"birth_city": "Paris",
|
||||||
|
"address": "999 avenue de France, 75001 Paris"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def check_date(date) -> bool:
|
def check_date(date) -> bool:
|
||||||
try:
|
try:
|
||||||
|
@ -31,7 +39,8 @@ def edit(update: Update, context: CallbackContext, data_edit: str):
|
||||||
name = data_edit.replace("edit_", "")
|
name = data_edit.replace("edit_", "")
|
||||||
if not rex[name].fullmatch(update.message.text) or\
|
if not rex[name].fullmatch(update.message.text) or\
|
||||||
(name == "birth_date" and not check_date(update.message.text)):
|
(name == "birth_date" and not check_date(update.message.text)):
|
||||||
context.bot.send_message(chat_id=update.effective_chat.id, text=f"Invalid value for `{local[name]}` \!",
|
context.bot.send_message(chat_id=update.effective_chat.id, text=f"Invalid value for `{local[name]}` \!\n"
|
||||||
|
f"*Example*: `{examples[name]}`",
|
||||||
parse_mode=ParseMode.MARKDOWN_V2)
|
parse_mode=ParseMode.MARKDOWN_V2)
|
||||||
else:
|
else:
|
||||||
s = db.Session()
|
s = db.Session()
|
||||||
|
|
|
@ -4,7 +4,6 @@ cffi==1.14.3
|
||||||
cryptography==3.2.1
|
cryptography==3.2.1
|
||||||
decorator==4.4.2
|
decorator==4.4.2
|
||||||
Pillow==8.0.1
|
Pillow==8.0.1
|
||||||
pkg-resources==0.0.0
|
|
||||||
pycparser==2.20
|
pycparser==2.20
|
||||||
PyPDF2==1.26.0
|
PyPDF2==1.26.0
|
||||||
python-telegram-bot==13.0
|
python-telegram-bot==13.0
|
||||||
|
|
Reference in a new issue