Удаление лишних файлов
This commit is contained in:
parent
ab66c05aef
commit
8064e107a2
@ -1,70 +0,0 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import CallbackQueryHandler, CallbackContext
|
||||
from utils.logger import logger
|
||||
from handlers.user_handlers import names_menu, user_start
|
||||
from utils.database import save_database, USER_DATA
|
||||
from handlers.database_handlers import show_names, clear_names
|
||||
from utils.message_sender import send_message
|
||||
from utils.user_data import get_user_info
|
||||
from handlers.admin_handlers import notify_admins
|
||||
|
||||
|
||||
async def handle_admin_buttons(update: Update, context: CallbackContext) -> None: #handlers/callback_handlers.py
|
||||
query = update.callback_query
|
||||
query.answer()
|
||||
del context.user_data['type']
|
||||
if query.data == 'admin_action1':
|
||||
bot.send_message(chat_id=query.message.chat_id, text="Выполнено админ действие 1")
|
||||
elif query.data == 'admin_action2':
|
||||
bot.send_message(chat_id=query.message.chat_id, text="Выполнено админ действие 2")
|
||||
|
||||
async def handle_user_buttons(update: Update, context: CallbackContext) -> None: #handlers/callback_handlers.py
|
||||
global USER_DATA
|
||||
if
|
||||
del context.user_data['type']
|
||||
query = update.callback_query
|
||||
await query.answer()
|
||||
|
||||
if query.data == "user_life":
|
||||
context.user_data['type'] = "О здравии"
|
||||
elif query.data == "user_dead":
|
||||
context.user_data['type'] = "За упокой"
|
||||
elif query.data == "user_comment":
|
||||
context.user_data['type'] = "Комментарий"
|
||||
elif query.data == "user_show":
|
||||
await show_names(update, context)
|
||||
return
|
||||
elif query.data == "user_send":
|
||||
try:
|
||||
save_database(USER_DATA)
|
||||
except:
|
||||
logger.error("Ошибка сохранения в файл json: {e}")
|
||||
return
|
||||
user_info = await get_user_info(update, context)
|
||||
# admin_notify(udate, context,)
|
||||
await notify_admins(update, context, user_info["name"])
|
||||
#Отправляем сообщение админам
|
||||
return
|
||||
elif query.data == "user_clear":
|
||||
try:
|
||||
del context.user_data['type']
|
||||
except:
|
||||
pass
|
||||
await clear_names(update, context)
|
||||
await user_start(update, context)
|
||||
return
|
||||
elif query.data == "user_clear_type":
|
||||
await clear_names(update, context)
|
||||
await names_menu(update, context)
|
||||
return
|
||||
# Переходим в меню имен только если выбран корректный тип
|
||||
if context.user_data.get('type'):
|
||||
await names_menu(update, context)
|
||||
else:
|
||||
await send_message(update, context,"Неверный запрос")
|
||||
|
||||
|
||||
def register_handlers(app):
|
||||
app.add_handler(CallbackQueryHandler(handle_user_buttons, pattern='^user_'))
|
||||
app.add_handler(CallbackQueryHandler(handle_admin_buttons, pattern='^admin_'))
|
||||
# app.add_handler(CallbackQueryHandler(handle_confirm_buttons, pattern='^confirm_'))
|
||||
@ -1,49 +0,0 @@
|
||||
from telegram import Update
|
||||
from telegram.ext import CommandHandler, MessageHandler, filters, CallbackContext
|
||||
from utils.logger import logger
|
||||
from handlers.user_handlers import user_keyboard
|
||||
from utils.message_sender import send_message
|
||||
from utils.prefixes import PREFIXES
|
||||
|
||||
async def parse_names(update: Update, context: CallbackContext) -> None:
|
||||
global USER_DATA
|
||||
|
||||
try:
|
||||
typen = context.user_data['type']
|
||||
user_info = await get_user_info(update)
|
||||
user_id = user_info["id"]
|
||||
|
||||
# Для комментария сохраняем весь текст
|
||||
if typen == "Комментарий":
|
||||
names = update.message.text.strip()
|
||||
else:
|
||||
# Парсим имена для других типов
|
||||
|
||||
names = parse_names_helper(update.message.text)
|
||||
|
||||
# Сохраняем данные
|
||||
if user_id not in USER_DATA:
|
||||
USER_DATA[user_id] = {}
|
||||
|
||||
if typen not in USER_DATA[user_id]:
|
||||
USER_DATA[user_id][typen] = []
|
||||
|
||||
# Для комментария сохраняем строку, для остальных - список
|
||||
if typen == "Комментарий":
|
||||
USER_DATA[user_id][typen] = names
|
||||
else:
|
||||
USER_DATA[user_id][typen].extend(names)
|
||||
|
||||
# Форматируем вывод
|
||||
if typen == "Комментарий":
|
||||
await send_message(update, context, f"Сохранен комментарий: {names}")
|
||||
else:
|
||||
saved_names = ', '.join(USER_DATA[user_id][typen])
|
||||
await send_message(update, context, f"{typen}: {saved_names}")
|
||||
logger.info(f"{USER_DATA}")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Ошибка при обработке: {e}")
|
||||
await send_message(update, context, "Произошла ошибка при обработке данных")
|
||||
del context.user_data['type']
|
||||
await send_message (update,context,"Выберите действие:", reply_markup=user_keyboard)
|
||||
Loading…
x
Reference in New Issue
Block a user