2020-11-07 12:16:52 +01:00
|
|
|
from telegram import Update, InlineKeyboardMarkup, InlineKeyboardButton, ParseMode
|
2020-11-07 00:45:05 +01:00
|
|
|
from telegram.ext import CallbackContext
|
|
|
|
|
2020-11-07 12:16:52 +01:00
|
|
|
from main import database, reasons
|
2020-11-07 00:45:05 +01:00
|
|
|
|
|
|
|
|
|
|
|
def new(update: Update, context: CallbackContext):
|
|
|
|
if update['_effective_user']['id'] not in database or not all(database[update['_effective_user']['id']].values()):
|
|
|
|
context.bot.send_message(chat_id=update.effective_chat.id, text="You have no data saved !",
|
|
|
|
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton("Set data",
|
|
|
|
callback_data="data")],
|
|
|
|
[InlineKeyboardButton("Home", callback_data="home")]
|
|
|
|
]))
|
|
|
|
else:
|
2020-11-07 12:16:52 +01:00
|
|
|
if update.effective_chat.id not in reasons:
|
|
|
|
reasons[update.effective_chat.id] = {}
|
|
|
|
if update["_effective_user"]["id"] not in reasons[update.effective_chat.id]:
|
|
|
|
reasons[update.effective_chat.id][update["_effective_user"]["id"]] = []
|
|
|
|
|
|
|
|
last_line = [InlineKeyboardButton("Home", callback_data="home")]
|
|
|
|
if len(reasons[update.effective_chat.id][update["_effective_user"]["id"]]) != 0:
|
|
|
|
last_line.append(InlineKeyboardButton("Send", callback_data="create"))
|
|
|
|
|
|
|
|
context.bot.send_message(chat_id=update.effective_chat.id,
|
|
|
|
text=f"Select your reasons\n`" +
|
|
|
|
"`, `".join(reasons[update.effective_chat.id][update["_effective_user"]["id"]]) +
|
|
|
|
"`",
|
|
|
|
parse_mode=ParseMode.MARKDOWN_V2,
|
|
|
|
reply_markup=InlineKeyboardMarkup([
|
|
|
|
[InlineKeyboardButton("Work", callback_data="reason_work"),
|
|
|
|
InlineKeyboardButton("Shopping", callback_data="reason_shopping")],
|
|
|
|
[InlineKeyboardButton("Health", callback_data="reason_health"),
|
|
|
|
InlineKeyboardButton("Family", callback_data="reason_family")],
|
|
|
|
[InlineKeyboardButton("Handicap", callback_data="reason_handicap"),
|
|
|
|
InlineKeyboardButton("Sport/animal", callback_data="reason_sport_animal")],
|
|
|
|
[InlineKeyboardButton("Injunction", callback_data="reason_injunction"),
|
|
|
|
InlineKeyboardButton("Missions", callback_data="reason_missions")],
|
|
|
|
[InlineKeyboardButton("Children", callback_data="reason_children")],
|
|
|
|
last_line]))
|
2020-11-07 00:45:05 +01:00
|
|
|
|