diff --git a/callbackQuery/create.py b/callbackQuery/create.py index 0471f2d..6506f7f 100644 --- a/callbackQuery/create.py +++ b/callbackQuery/create.py @@ -1,9 +1,42 @@ +from datetime import datetime +from io import BytesIO + +from qrcode import make from telegram import Update from telegram.ext import CallbackContext -from main import reasons +from main import reasons, database + + +local = { + "work": "travail", + "shopping": "achats", + "health": "sante", + "family": "famille", + "handicap": "handicap", + "sport_animal": "sport_animaux", + "injunction": "convocation", + "missions": "missions", + "children": "enfants" +} def create(update: Update, context: CallbackContext): + reason = map(lambda r: local[r], reasons[update.effective_chat.id][update["_effective_user"]["id"]]) del reasons[update.effective_chat.id][update["_effective_user"]["id"]] + date = datetime.now().strftime('%d/%m/%Y a %Hh%M') + + img = make(f"Cree le: {date};\n" + f"Nom: {database[update['_effective_user']['id']]['last_name']};\n" + f"Prenom: {database[update['_effective_user']['id']]['first_name']};\n" + f"Naissance: {database[update['_effective_user']['id']]['birth_date']} a " + f"{database[update['_effective_user']['id']]['birth_city']};\n" + f"Adresse: {database[update['_effective_user']['id']]['address']};\n" + f"Sortie: {date}\n" + f"Motifs: {', '.join(reason)};") + photo = BytesIO() + photo.name = "QRCode.jpeg" + img.save(photo, "JPEG") + photo.seek(0) + context.bot.send_photo(chat_id=update.effective_chat.id, photo=photo) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..fabef72 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,14 @@ +APScheduler==3.6.3 +certifi==2020.6.20 +cffi==1.14.3 +cryptography==3.2.1 +decorator==4.4.2 +Pillow==8.0.1 +pkg-resources==0.0.0 +pycparser==2.20 +python-telegram-bot==13.0 +pytz==2020.4 +qrcode==6.1 +six==1.15.0 +tornado==6.1 +tzlocal==2.1