Files
2025-12-24 02:06:17 +01:00

65 lines
2.7 KiB
Python

import os
from config import config
import log
from telegram import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import ContextTypes
import user_permissions
import traceback
os.makedirs(config.EVENTS_FOLDER, exist_ok=True)
async def list_event_actions(update: Update, context: ContextTypes.DEFAULT_TYPE, query: CallbackQuery):
if not user_permissions.is_user_admin(update.effective_user.id):
log.warning(chat_id=update.effective_chat.id, message=f"Unauthorized direct message access attempt by user {update.effective_user.id}\n{traceback.format_exc()}")
await update.message.reply_text("You are not authorized to use this bot in this chat.")
return
keyboard = [
[InlineKeyboardButton("Neues Event anlegen", callback_data='new_event')],
[InlineKeyboardButton("Event bearbeiten", callback_data='edit_event')],
[InlineKeyboardButton("Event löschen", callback_data='delete_event')]
]
await query.message.reply_text(
f'Was möchtest du machen?',
reply_markup=InlineKeyboardMarkup(keyboard)
)
async def new_event(update: Update, context: ContextTypes.DEFAULT_TYPE, query: CallbackQuery):
if not user_permissions.is_user_admin(update.effective_user.id):
log.warning(chat_id=update.effective_chat.id, message=f"Unauthorized direct message access attempt by user {update.effective_user.id}\n{traceback.format_exc()}")
await update.message.reply_text("You are not authorized to use this bot in this chat.")
return
keyboard = [
[InlineKeyboardButton("Anmelden", callback_data='register')],
[InlineKeyboardButton("Abmelden", callback_data='cancelRegister')]
]
await query.message.reply_text(
f'Welches Event möchtest du anpassen?',
reply_markup=InlineKeyboardMarkup(keyboard)
)
async def edit_event(update: Update, context: ContextTypes.DEFAULT_TYPE, query: CallbackQuery):
if not user_permissions.is_user_admin(update.effective_user.id):
log.warning(chat_id=update.effective_chat.id, message=f"Unauthorized direct message access attempt by user {update.effective_user.id}\n{traceback.format_exc()}")
await update.message.reply_text("You are not authorized to use this bot in this chat.")
return
keyboard = [
[InlineKeyboardButton("Anmelden", callback_data='register')],
[InlineKeyboardButton("Abmelden", callback_data='cancelRegister')]
]
await query.message.reply_text(
f'Welches Event möchtest du anpassen?',
reply_markup=InlineKeyboardMarkup(keyboard)
)
# TODO: Implement edit event logic
async def delete_event(update: Update, context: ContextTypes.DEFAULT_TYPE, query: CallbackQuery):
# TODO
pass