Spaces:
Runtime error
Runtime error
File size: 902 Bytes
8d21059 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # utils/guards.py
import functools
import logging
from telegram import Update
from telegram.ext import ContextTypes
import config
logger = logging.getLogger(__name__)
def is_admin(uid: int) -> bool:
return uid in config.ADMIN_IDS
def admin_only(func):
@functools.wraps(func)
async def wrapper(update: Update, ctx: ContextTypes.DEFAULT_TYPE):
uid = update.effective_user.id if update.effective_user else 0
if not is_admin(uid):
logger.warning(f"[GUARD] ุฑููุถ uid={uid} โ {func.__name__}")
if update.message:
await update.message.reply_text("โ ูุฐุง ุงูุฃู
ุฑ ููู
ุดุฑููู ููุท.")
elif update.callback_query:
await update.callback_query.answer("โ ูุฐุง ุงูุฃู
ุฑ ููู
ุดุฑููู ููุท.", show_alert=True)
return
return await func(update, ctx)
return wrapper
|