From aa1fb245f502fe3644a9d910139dec5e02037257 Mon Sep 17 00:00:00 2001 From: owl Date: Wed, 5 Mar 2025 15:43:03 +0700 Subject: [PATCH] restrict prompting to myself --- bot.py | 6 ++++-- tgbot/config.py | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 480c993..689a2ab 100644 --- a/bot.py +++ b/bot.py @@ -3,7 +3,7 @@ from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler, Messa CallbackContext, CallbackQueryHandler import logging -from tgbot.config import TOKEN +from tgbot.config import TOKEN, PROMPTING_USERS from tgbot.shit.handlers import handle_xitter, handle_red_ebalo, handle_hentai, handle_cute_button from tgbot.shit.prompting import gen_image from tgbot.shit.render import render_text_on_image, image_to_string @@ -23,7 +23,7 @@ async def start(update: Update, context: ContextTypes.DEFAULT_TYPE): async def handle_text(update: Update, context: ContextTypes.DEFAULT_TYPE): - if not update.message.text.startswith("prompting"): + if not update.message.text.startswith("prompting") or update.message.from_user["username"] not in PROMPTING_USERS: file = render_text_on_image("tgbot/assets/red_ebalo.png", update.message.text) await context.bot.send_sticker(chat_id=update.effective_chat.id, sticker=file) else: @@ -57,6 +57,7 @@ async def callback_query_handler(update: Update, context: CallbackContext): else: await query.answer() + async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE): query = update.inline_query.query if not query: @@ -76,6 +77,7 @@ async def handle_inline(update: Update, context: ContextTypes.DEFAULT_TYPE): await handle_red_ebalo(update, context) + def main(): application = ApplicationBuilder().token(TOKEN).build() diff --git a/tgbot/config.py b/tgbot/config.py index 63d4927..d926b82 100644 --- a/tgbot/config.py +++ b/tgbot/config.py @@ -12,3 +12,5 @@ DANBOORU_API_KEY = os.getenv("DANBOORU_API_KEY") IMAGE_GENERATOR_TOKEN: str = os.getenv("IMAGE_GENERATOR_TOKEN") IMAGE_GENERATOR_API_HOST: str = os.getenv("IMAGE_GENERATOR_API_HOST") CDN_URL: str = os.getenv("CDN_URL") + +PROMPTING_USERS: list = os.getenv("PROMPTING_USERS").split(" ")