Archived
1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
teleexit/callbackQuery/data.py

36 lines
2.2 KiB
Python
Raw Normal View History

from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ParseMode, Update
from telegram.ext import CallbackContext
2020-11-07 15:15:44 +01:00
import db
def data(update: Update, context: CallbackContext):
2020-11-07 15:15:44 +01:00
s = db.Session()
u = s.query(db.User).get(update["_effective_user"]["id"])
if not u:
u = db.User(update["_effective_user"]["id"])
s.add(u)
s.commit()
2020-11-07 16:04:53 +01:00
u = s.query(db.User).get(update["_effective_user"]["id"])
2020-11-07 15:15:44 +01:00
s.close()
context.bot.send_message(chat_id=update.effective_chat.id,
2020-11-07 15:15:44 +01:00
text=f"*Firstname*: `{u.first_name}`\n"
f"*Lastname*: `{u.last_name}`\n"
f"*Birth date*: `{u.birth_date}`\n"
f"*Birth city*: `{u.birth_city}`\n"
f"*Address*: `{u.address}`\n\n"
f"Choose the data you want to edit",
parse_mode=ParseMode.MARKDOWN_V2,
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Firstname",
callback_data="edit_first_name"),
InlineKeyboardButton("Lastname",
callback_data="edit_last_name")],
[InlineKeyboardButton("Birth date",
callback_data="edit_birth_date"),
InlineKeyboardButton("Birth city",
callback_data="edit_birth_city")],
[InlineKeyboardButton("Address",
callback_data="edit_address")],
2020-11-07 15:34:03 +01:00
[InlineKeyboardButton("🏘 Home",
callback_data="home")]]))