def resumes_for_vacation(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END query = update.callback_query language = context.user_data['user'].get('language') vacation_id = query.data.split(':')[1] if vacation_id == 'back': Navigation.to_account(update, context) return ConversationHandler.END resumes = vacations.get_resumes_for_vacation(vacation_id) if len(resumes) == 0: empty_message = strings.get_string('vacations.resumes.empty', language) query.answer(text=empty_message, show_alert=True) return LIST if type(resumes) is dict: resumes = list(resumes.values()) context.user_data['found_resumes'] = resumes context.user_data['current_page'] = 1 first_resume = resumes[0] user = users.user_exists(first_resume.get('user_id')) vacation_message = strings.from_resume(first_resume, language, for_vacation=True, user=user) vacations_keyboard = keyboards.get_list_paginated_keyboard( resumes, language) query.edit_message_text(text=vacation_message, reply_markup=vacations_keyboard, parse_mode=ParseMode.HTML) return RESUMES
def news(update, context): context.user_data['user'] = users.user_exists(update.message.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.message.reply_text(blocked_message) return if context.user_data['user'].get('language') == 'uz': news_message = settings.get_settings().get('news_uz') else: news_message = settings.get_settings().get('news') news_message = utils.replace_new_line(news_message) news_keyboard = keyboards.get_keyboard( 'news', language=context.user_data['user'].get('language')) image = images.get_news_image() if image: chat_id = update.message.chat_id message = context.bot.send_photo(chat_id=chat_id, photo=image, caption=news_message, parse_mode=ParseMode.HTML, reply_markup=news_keyboard) else: message = update.message.reply_text(text=news_message, parse_mode=ParseMode.HTML, reply_markup=news_keyboard) if 'news_message_id' in context.user_data: try: context.bot.delete_message( chat_id=update.message.chat_id, message_id=context.user_data['news_message_id']) except BadRequest: pass context.user_data['news_message_id'] = message.message_id
def faq(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return if context.user_data['user'].get('language') == 'uz': faq_message = settings.get_settings().get('faq_uz') else: faq_message = settings.get_settings().get('faq') faq_message = utils.replace_new_line(faq_message) faq_keyboard = keyboards.get_keyboard( 'faq', language=context.user_data['user'].get('language')) context.bot.delete_message( chat_id=update.effective_chat.id, message_id=update.callback_query.message.message_id) image = images.get_faq_image(context.user_data['user'].get('language')) if image: chat_id = update.effective_message.chat_id context.bot.send_photo(chat_id=chat_id, photo=image, caption=faq_message, parse_mode=ParseMode.HTML, reply_markup=faq_keyboard) else: update.effective_message.reply_text(text=faq_message, parse_mode=ParseMode.HTML, reply_markup=faq_keyboard)
def paginated_resumes(update, context): query = update.callback_query language = context.user_data['user'].get('language') page = query.data.split(':')[1] if page == 'back': user_id = context.user_data['user'].get('id') user_vacations = users.get_user_vacations(user_id) list_message = strings.get_string('vacations.resumes.select', language) list_keyboard = keyboards.get_vacations_keyboard( user_vacations, language, include_create_button=False) query.edit_message_text(text=list_message, reply_markup=list_keyboard) return LIST if int(page) == context.user_data['current_page']: return RESUMES resume = context.user_data['found_resumes'][int(page) - 1] user = users.user_exists(resume.get('user_id')) resume_message = strings.from_resume(resume, language, for_vacation=True, user=user) resume_keyboard = keyboards.get_list_paginated_keyboard( context.user_data['found_resumes'], language, current_page=int(page)) query.edit_message_text(text=resume_message, reply_markup=resume_keyboard, parse_mode=ParseMode.HTML) context.user_data['current_page'] = int(page) return RESUMES
def edit_action(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END query = update.callback_query data = query.data language = context.user_data['user'].get('language') if data == 'title': message = strings.get_string('resumes.edit.title', language) elif data == 'description': message = strings.get_string('resumes.edit.description', language) elif data == 'contacts': message = strings.get_string('resumes.edit.contacts', language) elif data == 'back': resume_message = strings.from_resume( context.user_data['editing_resume'], language) resume_keyboard = keyboards.get_keyboard('resume', language) query.edit_message_text(text=resume_message, reply_markup=resume_keyboard) return RESUME_ACTION else: return EDIT_ACTION keyboard = keyboards.get_keyboard('go_back', language) context.user_data['editing_resume_step'] = data context.bot.delete_message(chat_id=query.message.chat.id, message_id=query.message.message_id) context.bot.send_message(chat_id=query.message.chat.id, text=message, reply_markup=keyboard, parse_mode=ParseMode.HTML) return UPDATE_RESUME
def partners(update, context): context.user_data['user'] = users.user_exists(update.message.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.message.reply_text(blocked_message) return bot_settings = settings.get_settings() language = context.user_data['user'].get('language') partners_keyboard = keyboards.get_keyboard('partners', language) if context.user_data['user'].get('language') == 'uz': ad_image_path = bot_settings.get('partners_ad_image_uz') partners_message = bot_settings.get('partners_uz') else: ad_image_path = bot_settings.get('partners_ad_image') partners_message = bot_settings.get('partners') if not partners_message: if context.user_data['user'].get('language') == 'uz': partners_message = bot_settings.get('partners_tariffs_uz') else: partners_message = bot_settings.get('partners_tariffs') partners_message = utils.replace_new_line(partners_message) if ad_image_path: if os.path.exists(ad_image_path): image = open(ad_image_path, 'rb') else: image = images.get_partners_image( context.user_data['user'].get('language')) else: image = images.get_partners_image( context.user_data['user'].get('language')) photo_message = None if image: chat_id = update.message.chat_id photo_message = context.bot.send_photo(chat_id=chat_id, photo=image) message = context.bot.send_message(chat_id=chat_id, text=partners_message, parse_mode=ParseMode.HTML, reply_markup=partners_keyboard) else: message = update.message.reply_text(text=partners_message, parse_mode=ParseMode.HTML, reply_markup=partners_keyboard) if 'partners_message_id' in context.user_data: try: context.bot.delete_message( chat_id=update.message.chat_id, message_id=context.user_data['partners_message_id']) except BadRequest: pass if 'partners_photo_id' in context.user_data: try: context.bot.delete_message( chat_id=update.message.chat_id, message_id=context.user_data['partners_photo_id']) except BadRequest: pass context.user_data['partners_message_id'] = message.message_id if photo_message: context.user_data['partners_photo_id'] = photo_message.message_id
def resume_action(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END language = context.user_data['user'].get('language') query = update.callback_query data = query.data if data == 'edit': return edit(update, context) elif data == 'delete': return delete(update, context) elif data == 'back': user_id = query.from_user.id user_resumes = users.get_user_resumes(user_id) keyboard = keyboards.get_resumes_keyboard(user_resumes, language) message = strings.get_string('resumes.list', language) query.edit_message_text(message, parse_mode=ParseMode.HTML, reply_markup=keyboard) del context.user_data['has_action'] return ConversationHandler.END else: return RESUME_ACTION
def create(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True query = update.callback_query context.user_data['resume'] = {} context.user_data['resume']['user_id'] = query.from_user.id language = context.user_data['user'].get('language') query.answer(text=strings.get_string('resumes.menu_has_gone', language), show_alert=True) message = strings.get_string('resumes.create.title', language) keyboard = keyboards.get_keyboard('go_back.one_time', language) context.bot.delete_message(chat_id=query.from_user.id, message_id=query.message.message_id) if 'catalog_photo_id' in context.user_data: try: context.bot.delete_message( chat_id=update.effective_chat.id, message_id=context.user_data['catalog_photo_id']) except BadRequest: pass context.bot.send_message(chat_id=query.from_user.id, text=message, reply_markup=keyboard, parse_mode=ParseMode.HTML) return TITLE
def vacations_list(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True query = update.callback_query language = context.user_data['user'].get('language') user_id = context.user_data['user'].get('id') user_vacations = users.get_user_vacations(user_id) if len(user_vacations) == 0: empty_message = strings.get_string('vacations.empty_list', language) query.answer(text=empty_message, show_alert=True) del context.user_data['has_action'] return ConversationHandler.END list_message = strings.get_string('vacations.resumes.select', language) list_keyboard = keyboards.get_vacations_keyboard( user_vacations, language, include_create_button=False) context.bot.delete_message(chat_id=user_id, message_id=query.message.message_id) context.bot.send_message(chat_id=user_id, text=list_message, reply_markup=list_keyboard, parse_mode=ParseMode.HTML) return LIST
def account_settings_back(update: Update, context: CallbackContext): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) query = update.callback_query account_keyboard = keyboards.get_account_keyboard( context.user_data['user']) query.edit_message_reply_markup(account_keyboard)
def account_settings(update: Update, context: CallbackContext): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) language = context.user_data['user'].get('language') query = update.callback_query settings_keyboard = keyboards.get_keyboard('account.settings', language) query.edit_message_reply_markup(settings_keyboard)
def catalog(update: Update, context: CallbackContext): query = update.callback_query context.user_data['user'] = users.user_exists(query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['catalog'] = {} return _to_catalog_action(update, context, new_message=True)
def start(update: Update, context): user_id = update.effective_user.id if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(user_id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return check_channel(update, context)
def start(update, context): message = update.message user_id = message.from_user.id if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(user_id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.message.reply_text(blocked_message) return check_channel(update, context)
def change_language(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return query = update.callback_query query.answer() language = context.user_data['user'].get('language') change_language_message = strings.get_string('account.select_language', language) keyboard = keyboards.get_keyboard('account.language', language) query.edit_message_caption(change_language_message, reply_markup=keyboard)
def handle_tariffs(update, context): query = update.callback_query if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(query.message.chat_id) if context.user_data['user'].get('language') == 'uz': tariffs_message = settings.get_settings().get('partners_tariffs_uz') else: tariffs_message = settings.get_settings().get('partners_tariffs') tariffs_message = utils.replace_new_line(tariffs_message) partners_keyboard = keyboards.get_keyboard( 'partners', context.user_data['user'].get('language')) try: query.edit_message_text(text=tariffs_message, parse_mode=ParseMode.HTML, reply_markup=partners_keyboard) except BadRequest: query.answer() pass
def resume(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True language = context.user_data['user'].get('language') query = update.callback_query resume_id = query.data.split(':')[1] resume = resumes.get_resume(resume_id) context.user_data['editing_resume'] = resume resume_message = strings.from_resume(resume, language) resume_keyboard = keyboards.get_keyboard('resume', language) query.edit_message_text(text=resume_message, reply_markup=resume_keyboard) return RESUME_ACTION
def about(update, context): context.user_data['user'] = users.user_exists(update.message.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string('blocked', context.user_data['user'].get('language')) update.message.reply_text(blocked_message) return if context.user_data['user'].get('language') == 'uz': about_message = settings.get_settings().get('about_uz') else: about_message = settings.get_settings().get('about') about_message = utils.replace_new_line(about_message) about_keyboard = keyboards.get_keyboard('about', language=context.user_data['user'].get('language')) message = update.message.reply_text(text=about_message, parse_mode=ParseMode.HTML, reply_markup=about_keyboard) if 'about_message_id' in context.user_data: try: context.bot.delete_message(chat_id=update.message.chat_id, message_id=context.user_data['about_message_id']) except BadRequest: pass context.user_data['about_message_id'] = message.message_id
def vacation(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True language = context.user_data['user'].get('language') query = update.callback_query vacation_id = query.data.split(':')[1] vacation = vacations.get_vacation(vacation_id) context.user_data['editing_vacation'] = vacation vacation_message = strings.from_vacation(vacation, language) vacation_keyboard = keyboards.get_keyboard('vacation', language) query.edit_message_text(text=vacation_message, reply_markup=vacation_keyboard) return VACATION_ACTION
def user_vacations(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return language = context.user_data['user'].get('language') query = update.callback_query user_id = query.from_user.id vacations = users.get_user_vacations(user_id) keyboard = keyboards.get_vacations_keyboard(vacations, language) message = strings.get_string('vacations.list', language) context.bot.delete_message(chat_id=user_id, message_id=query.message.message_id) context.bot.send_message(chat_id=user_id, text=message, reply_markup=keyboard, parse_mode=ParseMode.HTML)
def start(update: Update, context): user = update.message.from_user user = users.user_exists(user.id) if not user: return context.user_data['user'] = user if user.get('is_blocked'): blocked_message = strings.get_string('blocked', user.get('language')) update.message.reply_text(blocked_message) return if user.get('user_role'): Navigation.to_account(update, context) else: select_role_message = strings.get_string('account.select_role', user.get('language')) select_role_keyboard = keyboards.get_keyboard('account.select_role', user.get('language')) update.message.reply_text(select_role_message, parse_mode=ParseMode.HTML, reply_markup=select_role_keyboard)
def to_account(update, context, new_message=False): if update.message: user_id = update.message.from_user.id elif update.callback_query: user_id = update.callback_query.from_user.id if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(user_id) user = context.user_data['user'] account_message = strings.get_user_info(user) account_keyboard = keyboards.get_account_keyboard(user) image = images.get_account_image(context.user_data['user'].get('user_role'), context.user_data['user'].get('language')) if update.message: if image: message = context.bot.send_photo(chat_id=user_id, photo=image, caption=account_message, reply_markup=account_keyboard) else: message = update.message.reply_text(text=account_message, reply_markup=account_keyboard) elif update.callback_query: if new_message: if image: message = context.bot.send_photo(chat_id=user_id, photo=image, caption=account_message, reply_markup=account_keyboard) else: message = context.bot.send_message(chat_id=user_id, text=account_message, reply_markup=account_keyboard) else: if image: context.bot.delete_message(chat_id=user_id, message_id=update.callback_query.message.message_id) message = context.bot.send_photo(chat_id=user_id, photo=image, caption=account_message, reply_markup=account_keyboard) else: update.callback_query.edit_message_text(text=account_message, reply_markup=account_keyboard) return else: return if 'account_message_id' in context.user_data: try: context.bot.delete_message(chat_id=user_id, message_id=context.user_data['account_message_id']) except BadRequest: pass context.user_data['account_message_id'] = message.message_id
def about(update: Update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return if context.user_data['user'].get('language') == 'uz': about_message = settings.get_settings().get('about_uz') else: about_message = settings.get_settings().get('about') about_message = utils.replace_new_line(about_message) about_keyboard = keyboards.get_keyboard( 'about', language=context.user_data['user'].get('language')) context.bot.delete_message( chat_id=update.effective_chat.id, message_id=update.callback_query.message.message_id) update.effective_message.reply_text(text=about_message, parse_mode=ParseMode.HTML, reply_markup=about_keyboard)
def start(update, context): user_id = update.message.from_user.id if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(user_id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.message.reply_text(blocked_message) return ConversationHandler.END context.user_data['has_action'] = True language = context.user_data['user'].get('language') bot_settings = settings.get_settings() support_message = bot_settings.get('support_' + language) if not support_message: support_message = strings.get_string( 'support.welcome', language).format(name=context.user_data['user'].get('name')) support_message = utils.replace_new_line(support_message) support_keyboard = keyboards.get_keyboard('support.cancel', language) image = None if bot_settings.get('support_image_' + language): try: image = open(bot_settings.get('support_image_' + language), 'rb') except FileNotFoundError: pass if not image: image = images.get_support_image(language) if image: chat_id = update.message.chat_id message = context.bot.send_photo(chat_id=chat_id, photo=image, caption=support_message, reply_markup=support_keyboard, parse_mode=ParseMode.HTML) else: message = update.message.reply_text(text=support_message, reply_markup=support_keyboard, parse_mode=ParseMode.HTML) context.user_data['support_message'] = message return SUPPORT
def start(update, context): user_id = update.effective_message.from_user.id if 'user' not in context.user_data: context.user_data['user'] = users.user_exists(user_id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string('blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END context.user_data['has_action'] = True language = context.user_data['user'].get('language') support_message = strings.get_string('support.welcome', language).format(name=context.user_data['user'].get('name')) support_keyboard = keyboards.get_keyboard('support.cancel', language) image = images.get_support_image(language) context.bot.delete_message(chat_id=update.effective_chat.id, message_id=update.callback_query.message.message_id) if image: chat_id = update.effective_message.chat_id message = context.bot.send_photo(chat_id=chat_id, photo=image, caption=support_message, reply_markup=support_keyboard, parse_mode=ParseMode.HTML) else: message = update.effective_message.reply_text(text=support_message, reply_markup=support_keyboard, parse_mode=ParseMode.HTML) context.user_data['support_message'] = message return SUPPORT
def change_role(update, context): context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return query = update.callback_query query.answer() language = context.user_data['user'].get('language') select_role_message = strings.get_string('account.select_role', language) select_role_keyboard = keyboards.get_keyboard('account.select_role', language) if 'mode' in context.user_data and context.user_data['mode'] == 'catalog': query.edit_message_text(select_role_message, parse_mode=ParseMode.HTML, reply_markup=select_role_keyboard) return query.edit_message_caption(select_role_message, parse_mode=ParseMode.HTML, reply_markup=select_role_keyboard)
def referral_start(update, context): user = users.user_exists(update.message.from_user.id) if user: if user.get('is_blocked'): blocked_message = strings.get_string('blocked', user.get('language')) update.message.reply_text(blocked_message) return ConversationHandler.END Navigation.to_main_menu(update, user.get('language'), user_name=user.get('name'), welcome=True, context=context) help_message = strings.get_string('start.help', user.get('language')) update.message.reply_text(help_message) return ConversationHandler.END if context.args: context.user_data['referral_from_id'] = context.args[0] languages_message = strings.get_string('start.languages') keyboard = keyboards.get_keyboard('start.languages') update.message.reply_text(languages_message, reply_markup=keyboard) return LANGUAGES
def referral_start(update: Update, context): user = users.user_exists(update.message.from_user.id) if user: if user.get('is_blocked'): blocked_message = strings.get_string('blocked', user.get('language')) update.message.reply_text(blocked_message) return ConversationHandler.END welcome_message = strings.get_string( 'start.welcome', user.get('language')).format( username=_get_user_name(update.effective_user)) remove_keyboard = keyboards.get_keyboard('remove') update.message.reply_text(welcome_message, reply_markup=remove_keyboard) Navigation.to_account(update, context, new_message=True) return ConversationHandler.END if context.args: context.user_data['referral_from_id'] = context.args[0] languages_message = strings.get_string('start.languages') keyboard = keyboards.get_keyboard('start.languages') update.message.reply_text(languages_message, reply_markup=keyboard) return LANGUAGES
def vacation_categories(update, context): user = context.user_data['user'] language = user.get('language') query = update.callback_query category_id = query.data.split(':')[1] if category_id == 'back': current_category = context.user_data['current_category'] if current_category.get('parent_id'): siblings_category = categories.get_siblings( current_category.get('id')) siblings_category = sorted(siblings_category, key=lambda i: i['position']) message = strings.get_category_description(current_category, language) keyboard = keyboards.get_categories_keyboard( siblings_category, language, context.user_data['vacation']['categories']) query.answer() query.edit_message_text(text=message, reply_markup=keyboard) context.user_data['current_category'] = categories.get_category( current_category.get('parent_id')) return CATEGORIES else: return to_parent_categories(query, context) if category_id == 'save': context.user_data['user'] = users.user_exists( update.callback_query.from_user.id) if context.user_data['user'].get('is_blocked'): blocked_message = strings.get_string( 'blocked', context.user_data['user'].get('language')) update.callback_query.answer(text=blocked_message, show_alert=True) return ConversationHandler.END if user.get(user.get('user_role') + '_tariff') or user.get('free_actions_count') > 0: payment_settings = settings.get_settings() item_cost = payment_settings.get( user.get(user.get('user_role') + '_tariff')) user_balance = user.get('balance_' + user.get('user_role')) if user_balance is None: user_balance = 0 if user_balance >= int(item_cost) or user.get( 'free_actions_count') > 0: result = vacations.create_vacation( context.user_data['vacation']) vacation = result.get('vacation') context.user_data['user'] = vacation.get('user') success_message = strings.get_string( 'vacations.create.success', language) help_message = strings.get_string( 'vacations.create.success.help', language) context.bot.delete_message(chat_id=query.message.chat.id, message_id=query.message.message_id) context.bot.send_message(chat_id=query.message.chat.id, text=success_message) menu_keyboard = keyboards.get_keyboard('menu', language) help_image = images.get_help_panel_image() if help_image: context.bot.send_photo(chat_id=query.message.chat_id, photo=help_image, caption=help_message, parse_mode=ParseMode.HTML, reply_markup=menu_keyboard) else: context.bot.send_message(chat_id=query.message.chat.id, text=help_message, parse_mode=ParseMode.HTML, reply_markup=menu_keyboard) Navigation.to_account(update, context, new_message=True) del context.user_data['vacation'] del context.user_data['has_action'] Notifications.notify_users_new_item(context.bot, result.get('notifyUsers'), 'vacations.notify.new') if result.get('notifyUsers'): Notifications.notify_users_new_item( context.bot, [user], 'resumes.notify.new') return ConversationHandler.END empty_balance = strings.get_string('empty_balance', language) query.answer(text=empty_balance, show_alert=True) return payments.start(update, context) category = categories.get_category(category_id) children_categories = category.get('categories') if 'categories' not in context.user_data['vacation']: context.user_data['vacation']['categories'] = [] if children_categories: children_categories = sorted(children_categories, key=lambda i: i['position']) keyboard = keyboards.get_categories_keyboard( children_categories, language, context.user_data['vacation']['categories']) message = strings.get_category_description(category, language) query.edit_message_text(message, reply_markup=keyboard) context.user_data['current_category'] = category return CATEGORIES else: if any(d['id'] == category['id'] for d in context.user_data['vacation']['categories']): added = False context.user_data['vacation']['categories'][:] = [ c for c in context.user_data['vacation']['categories'] if c.get('id') != category.get('id') ] else: if len(context.user_data['vacation']['categories']) == 10: limit_message = strings.get_string('categories.limit', language) query.answer(text=limit_message, show_alert=True) return CATEGORIES added = True context.user_data['vacation']['categories'].append(category) category_siblings = categories.get_siblings(category_id) category_siblings = sorted(category_siblings, key=lambda i: i['position']) keyboard = keyboards.get_categories_keyboard( category_siblings, language, context.user_data['vacation']['categories']) message = strings.from_categories( category, context.user_data['vacation']['categories'], added, language) answer_message = strings.from_categories_message( category, context.user_data['vacation']['categories'], added, language) query.answer(text=answer_message) query.edit_message_text(message, reply_markup=keyboard) return CATEGORIES