Skip to content

Commit

Permalink
Merge pull request #148 from MikiEremiki/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
MikiEremiki authored Feb 7, 2024
2 parents 8015e83 + e3a4fab commit 7fd8a4f
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 44 deletions.
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion src/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
42 changes: 26 additions & 16 deletions src/handlers/birthday_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}'
Expand All @@ -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
)

Expand All @@ -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)]
Expand All @@ -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(
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -545,19 +557,17 @@ 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'
'__________\n'
'В случае переноса или отмены свяжитесь с Администратором:\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
)

Expand Down
2 changes: 2 additions & 0 deletions src/handlers/main_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
16 changes: 8 additions & 8 deletions src/handlers/reserve_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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'][
Expand Down
32 changes: 31 additions & 1 deletion src/handlers/sub_hl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)


Expand Down Expand Up @@ -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}')
5 changes: 4 additions & 1 deletion src/utilities/schemas/context_bot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
'username': str,
'phone': str,
'contacts': str,
}
},
'birthday_price': {
int: (int, str),
},
}
46 changes: 32 additions & 14 deletions src/utilities/utl_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7fd8a4f

Please sign in to comment.