From c0118edfbe40f0b0308fcdccb31482e140564bd7 Mon Sep 17 00:00:00 2001 From: MikiEremiki Date: Tue, 6 Feb 2024 23:00:36 +0300 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20=D0=9E=D1=82=D0=BA=D0=BB=D1=8E=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=BE=D1=81=D1=82=D0=B8=20=D0=BE=D1=82=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B2=D0=B8=D1=81=D0=B0=20postgres?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-compose.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f95798c..f8134c4 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -8,9 +8,9 @@ services: context: . image: baby_domik:v1 restart: always - depends_on: - postgres: - condition: service_healthy +# depends_on: +# postgres: +# condition: service_healthy networks: - network environment: From e3a4faba6f5fedb3788a7c610f7ebcf7ab507de9 Mon Sep 17 00:00:00 2001 From: MikiEremiki Date: Thu, 8 Feb 2024 01:08:10 +0300 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE=D1=81?= =?UTF-8?q?=D0=BC=D0=BE=D1=82=D1=80=D0=B0,=20=D1=87=D0=B8=D1=81=D1=82?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=B8=20=D1=83=D1=81=D1=82=D0=B0=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B8=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B9=20=D1=81=D1=82=D0=BE=D0=B8=D0=BC=D0=BE=D1=81=D1=82=D0=B8?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=B4=D0=BD=D0=B5=D0=B9=20=D1=80=D0=BE?= =?UTF-8?q?=D0=B6=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bot.py | 6 ++- src/handlers/birthday_hl.py | 42 +++++++++++++-------- src/handlers/main_hl.py | 2 + src/handlers/reserve_hl.py | 16 ++++---- src/handlers/sub_hl.py | 32 +++++++++++++++- src/utilities/schemas/context_bot_data.py | 5 ++- src/utilities/utl_func.py | 46 ++++++++++++++++------- 7 files changed, 108 insertions(+), 41 deletions(-) diff --git a/src/bot.py b/src/bot.py index b71b9db..b833e4b 100644 --- a/src/bot.py +++ b/src/bot.py @@ -11,7 +11,7 @@ from handlers import main_hl from handlers.error_hl import error_handler from handlers.sub_hl import ( - update_ticket_data, update_show_data, update_admin_info + update_ticket_data, update_show_data, update_admin_info, update_bd_price ) from handlers.timeweb_hl import get_balance from conv_hl.reserve_conv_hl import reserve_conv_hl @@ -89,6 +89,10 @@ def bot(): COMMAND_DICT['UP_S_DATA'][0], update_show_data, filters=filters.User(ADMIN_ID))) + application.add_handler(CommandHandler( + COMMAND_DICT['UP_BD_PRICE'][0], + update_bd_price, + filters=filters.User(ADMIN_ID))) application.add_handler(CommandHandler( COMMAND_DICT['LOG'][0], send_log, diff --git a/src/handlers/birthday_hl.py b/src/handlers/birthday_hl.py index 4878c81..2234ae2 100644 --- a/src/handlers/birthday_hl.py +++ b/src/handlers/birthday_hl.py @@ -326,6 +326,10 @@ async def get_qty_adult(update: Update, context: ContextTypes.DEFAULT_TYPE): reply_markup = None birthday_place = context.user_data['birthday_user_data']['place'] + birthday_price = context.bot_data.get( + 'birthday_price', + {1: 0, 2: 0, 3: 0} + ) if birthday_place == 1: one_option = f'{DICT_OF_EMOJI_FOR_BUTTON[1]}' two_option = f'{DICT_OF_EMOJI_FOR_BUTTON[2]}' @@ -334,10 +338,10 @@ async def get_qty_adult(update: Update, context: ContextTypes.DEFAULT_TYPE): text += escape_markdown( f'{one_option} Спектакль (40 минут) + ' 'аренда комнаты под чаепитие (1 час)\n' - ' 15000 руб\n\n' + f' {birthday_price[1]} руб\n\n' f'{two_option} Спектакль (40 минут) + ' 'аренда комнаты под чаепитие + серебряная дискотека (1 час)\n' - ' 20000 руб', + f' {birthday_price[2]} руб', 2 ) @@ -350,10 +354,10 @@ async def get_qty_adult(update: Update, context: ContextTypes.DEFAULT_TYPE): 'Формат «На выезде»:\n\n' 'Спектакль (40 минут) + Свободная игра с персонажами и ' 'фотосессия (20 минут)\n' - '25000р\n\n', + f' {birthday_price[3]} руб\n\n', 2 ) - text += do_italic('Нажмите далее') + text += do_italic('Нажмите Далее') reply_markup = InlineKeyboardMarkup([ [InlineKeyboardButton('Далее', callback_data=3)] @@ -380,15 +384,19 @@ async def get_format_bd(update: Update, context: ContextTypes.DEFAULT_TYPE): birthday_hl_logger.info(join_for_log_info( context.user_data['user'].id, 'формат праздника', format_bd)) + birthday_price = context.bot_data.get( + 'birthday_price', + {1: 0, 2: 0, 3: 0} + ) text = 'Формат проведения Дня рождения\n\n' match format_bd: case '1': - text += f'Спектакль + чаепитие\n 15000 руб' + text += f'Спектакль + чаепитие\n {birthday_price[1]} руб' case '2': - text += f'Спектакль + чаепитие + дискотека\n 20000 руб' + text += (f'Спектакль + чаепитие + дискотека\n {birthday_price[2]} руб') case '3': - text += f'Спектакль + игра + фотосессия\n 25000 руб' + text += f'Спектакль + игра + фотосессия\n {birthday_price[3]} руб' await query.edit_message_text(text) await update.effective_chat.send_message( @@ -464,20 +472,24 @@ async def get_phone(update: Update, context: ContextTypes.DEFAULT_TYPE): 'dict_of_shows'] item = dict_of_shows[item]['full_name'] case 'format_bd': + birthday_price = context.bot_data.get( + 'birthday_price', + {1: 0, 2: 0, 3: 0} + ) if item == 1: item = ('Спектакль (40 минут) + ' 'аренда комнаты под чаепитие (1 час) ' - '-> 15000 руб') + f'-> {birthday_price[1]} руб') elif item == 2: item = ('Спектакль (40 минут) + ' 'аренда комнаты под чаепитие + ' 'серебряная дискотека (1 час) ' - '-> 20000 руб') + f'-> {birthday_price[2]} руб') elif item == 3: item = ('Спектакль (40 минут) + ' 'Свободная игра с персонажами и ' 'фотосессия (20 минут)' - '-> 25000 руб') + f'-> {birthday_price[3]} руб') case 'phone': item = '+7' + item @@ -545,9 +557,8 @@ async def paid_info(update: Update, context: ContextTypes.DEFAULT_TYPE): text = (' Внесите предоплату 5000 руб\n\n' 'Оплатить можно:\n' - ' - По qr-коду\n' - ' - Переводом в банк Точка по номеру телефона +79159383529' - '- Татьяна Александровна Б.\n\n' + ' - Переводом на карту Сбербанка по номеру телефона' + '+79159383529 Татьяна Александровна Б.\n\n' 'ВАЖНО! Прислать сюда электронный чек об оплате (или скриншот)\n' 'Пожалуйста внесите оплату в течении 30 минут или нажмите ' 'отмена\n\n' @@ -555,9 +566,8 @@ async def paid_info(update: Update, context: ContextTypes.DEFAULT_TYPE): 'В случае переноса или отмены свяжитесь с Администратором:\n' f'{context.bot_data['admin']['contacts']}') - message = await update.effective_chat.send_photo( - photo=FILE_ID_QR, - caption=text, + message = await update.effective_chat.send_message( + text=text, reply_markup=reply_markup ) diff --git a/src/handlers/main_hl.py b/src/handlers/main_hl.py index 3d3b982..d7cc2b8 100644 --- a/src/handlers/main_hl.py +++ b/src/handlers/main_hl.py @@ -496,6 +496,8 @@ async def cancel(update: Update, context: ContextTypes.DEFAULT_TYPE): context.user_data['birthday_user_data'].clear() if context.user_data.get('reserve_user_data', False): context.user_data['reserve_user_data'].clear() + context.user_data.pop('STATE') + context.user_data.pop('command') return ConversationHandler.END diff --git a/src/handlers/reserve_hl.py b/src/handlers/reserve_hl.py index 6d83b93..d5ce7fc 100644 --- a/src/handlers/reserve_hl.py +++ b/src/handlers/reserve_hl.py @@ -100,8 +100,7 @@ async def choice_month(update: Update, context: ContextTypes.DEFAULT_TYPE): 'Выполните команду в правильном топике') return ConversationHandler.END - reserve_hl_logger.info(f'Пользователь начал выбор месяца:' - f' {user}') + reserve_hl_logger.info(f'Пользователь начал выбор месяца: {user}') message = await send_and_del_message_to_remove_kb(update) await update.effective_chat.send_action(ChatAction.TYPING) @@ -123,7 +122,7 @@ async def choice_month(update: Update, context: ContextTypes.DEFAULT_TYPE): 'Но вы можете забронировать место связавшись напрямую с ' 'Администратором:\n' f'{context.bot_data['admin']['contacts']}', - message_thread_id=update.message.message_thread_id + message_thread_id=update.effective_message.message_thread_id ) return ConversationHandler.END except TimeoutError: @@ -133,10 +132,10 @@ async def choice_month(update: Update, context: ContextTypes.DEFAULT_TYPE): f'Обработчик завершился на этапе {state}') await update.effective_chat.send_message( text='Произошел разрыв соединения, попробуйте еще раз\n' - 'Если проблема повторится вы можете оформить заявку напрямую у ' - 'Администратора:\n' + 'Если проблема повторится вы можете оформить заявку ' + 'напрямую у Администратора:\n' f'{context.bot_data['admin']['contacts']}', - message_thread_id=update.message.message_thread_id + message_thread_id=update.effective_message.message_thread_id ) return ConversationHandler.END @@ -169,10 +168,11 @@ async def choice_month(update: Update, context: ContextTypes.DEFAULT_TYPE): await update.effective_chat.send_message( text=text, reply_markup=reply_markup, - message_thread_id=update.message.message_thread_id + message_thread_id=update.effective_message.message_thread_id ) - context.user_data['common_data']['dict_of_shows'] = dict_of_shows + context.user_data['common_data'][ + 'dict_of_shows'] = dict_of_shows context.user_data['reserve_user_data'][ 'dict_of_name_show'] = dict_of_name_show context.user_data['reserve_user_data'][ diff --git a/src/handlers/sub_hl.py b/src/handlers/sub_hl.py index a2f7312..be06c7a 100644 --- a/src/handlers/sub_hl.py +++ b/src/handlers/sub_hl.py @@ -27,7 +27,7 @@ async def send_and_del_message_to_remove_kb(update: Update): return await update.effective_chat.send_message( text='Загружаем данные', reply_markup=ReplyKeyboardRemove(), - message_thread_id=update.message.message_thread_id + message_thread_id=update.effective_message.message_thread_id ) @@ -145,3 +145,33 @@ async def remove_inline_button(update: Update): await query.edit_message_reply_markup() return query + + +async def update_bd_price(update: Update, + context: ContextTypes.DEFAULT_TYPE) -> None: + birthday_price = context.bot_data.setdefault('birthday_price', {}) + if context.args: + if context.args[0] == 'clean': + context.bot_data['birthday_price'] = {} + await update.effective_chat.send_message( + f'Зафиксировано: {context.bot_data['birthday_price']}') + return + if len(context.args) % 2 == 0: + for i in range(0, len(context.args), 2): + birthday_price[int(context.args[i])] = int(context.args[i+1]) + await update.effective_chat.send_message( + f'Зафиксировано: {context.bot_data['birthday_price']}') + else: + await update.effective_chat.send_message( + f'Должно быть четное кол-во параметров\n' + f'Передано {len(context.args)}\n' + 'Формат: 1 15000 2 20000\n' + 'В качестве разделителей только пробелы') + else: + await update.effective_chat.send_message( + 'Не заданы параметры к команде\n' + '1 - Спектакль (40 минут) + аренда комнаты под чаепитие (1 час)\n' + '2 - Спектакль (40 минут) + аренда комнаты под чаепитие + серебряная дискотека (1 час)\n' + '3 - Спектакль (40 минут) + Свободная игра с персонажами и фотосессия (20 минут)\n' + 'Текущие цены заказных мероприятий:\n' + f'{birthday_price}') diff --git a/src/utilities/schemas/context_bot_data.py b/src/utilities/schemas/context_bot_data.py index 3342430..7d04783 100644 --- a/src/utilities/schemas/context_bot_data.py +++ b/src/utilities/schemas/context_bot_data.py @@ -32,5 +32,8 @@ 'username': str, 'phone': str, 'contacts': str, - } + }, + 'birthday_price': { + int: (int, str), + }, } diff --git a/src/utilities/utl_func.py b/src/utilities/utl_func.py index 5952af5..9438896 100644 --- a/src/utilities/utl_func.py +++ b/src/utilities/utl_func.py @@ -113,27 +113,45 @@ async def delete_message_for_job_in_callback( async def set_menu(bot: ExtBot) -> None: utilites_logger.info('Начало настройки команд') default_commands = [ - BotCommand(COMMAND_DICT['START'][0], COMMAND_DICT['START'][1]), - BotCommand(COMMAND_DICT['RESERVE'][0], COMMAND_DICT['RESERVE'][1]), - BotCommand(COMMAND_DICT['BD_ORDER'][0], COMMAND_DICT['BD_ORDER'][1]), + BotCommand(COMMAND_DICT['START'][0], + COMMAND_DICT['START'][1]), + BotCommand(COMMAND_DICT['RESERVE'][0], + COMMAND_DICT['RESERVE'][1]), + BotCommand(COMMAND_DICT['BD_ORDER'][0], + COMMAND_DICT['BD_ORDER'][1]), ] admin_group_commands = [ - BotCommand(COMMAND_DICT['LIST'][0], COMMAND_DICT['LIST'][1]), - BotCommand(COMMAND_DICT['LIST_WAIT'][0], COMMAND_DICT['LIST_WAIT'][1]), + BotCommand(COMMAND_DICT['LIST'][0], + COMMAND_DICT['LIST'][1]), + BotCommand(COMMAND_DICT['LIST_WAIT'][0], + COMMAND_DICT['LIST_WAIT'][1]), ] sub_admin_commands = default_commands + admin_group_commands admin_commands = sub_admin_commands + [ - BotCommand(COMMAND_DICT['AFISHA'][0], COMMAND_DICT['AFISHA'][1]), - BotCommand(COMMAND_DICT['ADM_INFO'][0], COMMAND_DICT['ADM_INFO'][1]), - BotCommand(COMMAND_DICT['UP_T_DATA'][0], COMMAND_DICT['UP_T_DATA'][1]), - BotCommand(COMMAND_DICT['UP_S_DATA'][0], COMMAND_DICT['UP_S_DATA'][1]), - BotCommand(COMMAND_DICT['CB_TW'][0], COMMAND_DICT['CB_TW'][1]), + BotCommand(COMMAND_DICT['RESERVE_ADMIN'][0], + COMMAND_DICT['RESERVE_ADMIN'][1]), + BotCommand(COMMAND_DICT['AFISHA'][0], + COMMAND_DICT['AFISHA'][1]), + BotCommand(COMMAND_DICT['ADM_INFO'][0], + COMMAND_DICT['ADM_INFO'][1]), + BotCommand(COMMAND_DICT['UP_T_DATA'][0], + COMMAND_DICT['UP_T_DATA'][1]), + BotCommand(COMMAND_DICT['UP_S_DATA'][0], + COMMAND_DICT['UP_S_DATA'][1]), + BotCommand(COMMAND_DICT['UP_BD_PRICE'][0], + COMMAND_DICT['UP_BD_PRICE'][1]), + BotCommand(COMMAND_DICT['CB_TW'][0], + COMMAND_DICT['CB_TW'][1]), ] backend_commands = [ - BotCommand(COMMAND_DICT['TOPIC_START'][0], COMMAND_DICT['TOPIC_START'][1]), - BotCommand(COMMAND_DICT['TOPIC_DEL'][0], COMMAND_DICT['TOPIC_DEL'][1]), - BotCommand(COMMAND_DICT['LOG'][0], COMMAND_DICT['LOG'][1]), - BotCommand(COMMAND_DICT['ECHO'][0], COMMAND_DICT['ECHO'][1]), + BotCommand(COMMAND_DICT['TOPIC_START'][0], + COMMAND_DICT['TOPIC_START'][1]), + BotCommand(COMMAND_DICT['TOPIC_DEL'][0], + COMMAND_DICT['TOPIC_DEL'][1]), + BotCommand(COMMAND_DICT['LOG'][0], + COMMAND_DICT['LOG'][1]), + BotCommand(COMMAND_DICT['ECHO'][0], + COMMAND_DICT['ECHO'][1]), ] superadmin_commands = admin_commands + backend_commands