diff --git a/app.json b/app.json index d559be083a..6e44570fd4 100644 --- a/app.json +++ b/app.json @@ -37,6 +37,10 @@ "description": "Allowed user in to use sudo command.", "value": "" }, + "OWNER_ID": { + "description": "OWNER OF THIS BOT.", + "value": "" + }, "GOOGLE_AI_KEY": { "description": "Your Gemini AI Key", "value": "", diff --git a/database/feds_db.py b/database/feds_db.py index ad0da3e0e7..e86134b6e2 100644 --- a/database/feds_db.py +++ b/database/feds_db.py @@ -3,7 +3,7 @@ import pytz from database import dbname -from misskaty.vars import SUDO +from misskaty.vars import SUDO, OWNER_ID fedsdb = dbname["federation"] @@ -64,7 +64,7 @@ async def is_user_fed_owner(fed_id, user_id: int): if not getfed: return False owner_id = getfed["owner_id"] - return user_id == owner_id or user_id not in SUDO + return user_id == owner_id or user_id not in SUDO or user_id != OWNER_ID async def search_fed_by_id(fed_id): diff --git a/misskaty/__main__.py b/misskaty/__main__.py index 95f76f5f4f..709c029c89 100644 --- a/misskaty/__main__.py +++ b/misskaty/__main__.py @@ -28,7 +28,7 @@ ) from misskaty.plugins import ALL_MODULES from misskaty.plugins.web_scraper import web -from misskaty.vars import SUDO, USER_SESSION +from misskaty.vars import OWNER_ID, USER_SESSION from utils import auto_clean LOGGER = getLogger("MissKaty") @@ -59,17 +59,11 @@ async def start_bot(): LOGGER.info("[INFO]: BOT STARTED AS @%s!", BOT_USERNAME) try: LOGGER.info("[INFO]: SENDING ONLINE STATUS") - for i in SUDO: - if USER_SESSION: - await app.send_message( - i, - f"USERBOT AND BOT STARTED with Pyrogram v{__version__}..\nUserBot: {UBOT_NAME}\nBot: {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n{bot_modules}", - ) - else: - await app.send_message( - i, - f"BOT STARTED with Pyrogram v{__version__} as {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n{bot_modules}", - ) + if USER_SESSION: + await app.send_message( + OWNER_ID, + f"USERBOT AND BOT STARTED with Pyrogram v{__version__}..\nUserBot: {UBOT_NAME}\nBot: {BOT_NAME}\n\nwith Pyrogram v{__version__} (Layer {layer}) started on @{BOT_USERNAME}.\n\n{bot_modules}", + ) except Exception as e: LOGGER.error(str(e)) scheduler.start() diff --git a/misskaty/core/decorator/permissions.py b/misskaty/core/decorator/permissions.py index e5d242fda7..9892aa70e6 100644 --- a/misskaty/core/decorator/permissions.py +++ b/misskaty/core/decorator/permissions.py @@ -9,7 +9,7 @@ from misskaty import app from misskaty.helper.sqlite_helper import Cache -from misskaty.vars import SUDO +from misskaty.vars import SUDO, OWNER_ID from ...helper.localization import ( default_language, @@ -165,7 +165,7 @@ async def subFunc2(client, message: Message, *args, **kwargs): # For admins and sudo users userID = message.from_user.id permissions = await member_permissions(chatID, userID) - if userID not in SUDO and permission not in permissions: + if userID not in SUDO or userID != OWNER_ID and permission not in permissions: return await unauthorised(message, permission, subFunc2) return await authorised(func, subFunc2, client, message, *args, **kwargs) diff --git a/misskaty/core/pyro_cooldown.py b/misskaty/core/pyro_cooldown.py index 04a43937ae..8793565994 100644 --- a/misskaty/core/pyro_cooldown.py +++ b/misskaty/core/pyro_cooldown.py @@ -3,7 +3,7 @@ from pyrogram import filters from pyrogram.errors import MessageDeleteForbidden -from misskaty.vars import SUDO +from misskaty.vars import SUDO, OWNER_ID data = {} @@ -28,7 +28,7 @@ async def task(msg, warn=False, sec=None): def wait(sec): async def ___(flt, _, msg): user_id = msg.from_user.id if msg.from_user else msg.sender_chat.id - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return True if user_id in data: if msg.date.timestamp() >= data[user_id]["timestamp"] + flt.data: diff --git a/misskaty/plugins/admin.py b/misskaty/plugins/admin.py index c3fae30829..89611db9de 100644 --- a/misskaty/plugins/admin.py +++ b/misskaty/plugins/admin.py @@ -53,7 +53,7 @@ time_converter, ) from misskaty.helper.localization import use_chat_lang -from misskaty.vars import COMMAND_HANDLER, SUDO +from misskaty.vars import COMMAND_HANDLER, SUDO, OWNER_ID LOGGER = getLogger("MissKaty") @@ -172,7 +172,7 @@ async def kickFunc(client: Client, ctx: Message, strings) -> "Message": return await ctx.reply_msg(strings("user_not_found")) if user_id == client.me.id: return await ctx.reply_msg(strings("kick_self_err")) - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return await ctx.reply_msg(strings("kick_sudo_err")) if user_id in (await list_admins(ctx.chat.id)): return await ctx.reply_msg(strings("kick_admin_err")) @@ -213,7 +213,7 @@ async def banFunc(client, message, strings): return await message.reply_text(strings("user_not_found")) if user_id == client.me.id: return await message.reply_text(strings("ban_self_err")) - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return await message.reply_text(strings("ban_sudo_err")) if user_id in (await list_admins(message.chat.id)): return await message.reply_text(strings("ban_admin_err")) @@ -299,7 +299,7 @@ async def unban_func(_, message, strings): # Ban users listed in a message @app.on_message( - filters.user(SUDO) & filters.command("listban", COMMAND_HANDLER) & filters.group + (filters.user(SUDO) | filters.user(OWNER_ID)) & filters.command("listban", COMMAND_HANDLER) & filters.group ) @use_chat_lang() async def list_ban_(c, message, strings): @@ -319,7 +319,7 @@ async def list_ban_(c, message, strings): if userid == c.me.id: return await message.reply_text(strings("ban_self_err")) - if userid in SUDO: + if userid in SUDO or user_id == OWNER_ID: return await message.reply_text(strings("ban_sudo_err")) splitted = messagelink.split("/") uname, mid = splitted[-2], int(splitted[-1]) @@ -353,7 +353,7 @@ async def list_ban_(c, message, strings): # Unban users listed in a message @app.on_message( - filters.user(SUDO) & filters.command("listunban", COMMAND_HANDLER) & filters.group + (filters.user(SUDO) | filters.user(OWNER_ID)) & filters.command("listunban", COMMAND_HANDLER) & filters.group ) @use_chat_lang() async def list_unban(_, message, strings): @@ -469,7 +469,7 @@ async def demote(client, message, strings): return await message.reply_text(strings("user_not_found")) if user_id == client.me.id: return await message.reply_text(strings("demote_self_err")) - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return await message.reply_text(strings("demote_sudo_err")) try: await message.chat.promote_member( @@ -535,7 +535,7 @@ async def mute(client, message, strings): return await message.reply_text(strings("user_not_found")) if user_id == client.me.id: return await message.reply_text(strings("mute_self_err")) - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return await message.reply_text(strings("mute_sudo_err")) if user_id in (await list_admins(message.chat.id)): return await message.reply_text(strings("mute_admin_err")) @@ -606,7 +606,7 @@ async def warn_user(client, message, strings): return await message.reply_text(strings("user_not_found")) if user_id == client.me.id: return await message.reply_text(strings("warn_self_err")) - if user_id in SUDO: + if user_id in SUDO or user_id == OWNER_ID: return await message.reply_text(strings("warn_sudo_err")) if user_id in (await list_admins(chat_id)): return await message.reply_text(strings("warn_admin_err")) diff --git a/misskaty/plugins/autoapprove.py b/misskaty/plugins/autoapprove.py index 7b05635ad4..d0d189c522 100644 --- a/misskaty/plugins/autoapprove.py +++ b/misskaty/plugins/autoapprove.py @@ -10,7 +10,7 @@ from database import dbname from misskaty import app from misskaty.core.decorator.permissions import adminsOnly, member_permissions -from misskaty.vars import COMMAND_HANDLER, SUDO +from misskaty.vars import COMMAND_HANDLER, SUDO, OWNER_ID approvaldb = dbname["autoapprove"] @@ -53,7 +53,7 @@ async def approval_cb(_, cb: CallbackQuery): permissions = await member_permissions(chat_id, from_user.id) permission = "can_restrict_members" if permission not in permissions: - if from_user.id not in SUDO: + if from_user.id not in SUDO or from_user.id != OWNER_ID: return await cb.answer( f"You don't have the required permission.\n Permission: {permission}", show_alert=True, diff --git a/misskaty/plugins/ban_user_or_chat.py b/misskaty/plugins/ban_user_or_chat.py index f7843172b0..d7aa377b96 100644 --- a/misskaty/plugins/ban_user_or_chat.py +++ b/misskaty/plugins/ban_user_or_chat.py @@ -7,7 +7,7 @@ from database.users_chats_db import db from misskaty import app from misskaty.helper.localization import use_chat_lang -from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO, SUPPORT_CHAT +from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO, OWNER_ID, SUPPORT_CHAT @app.on_message(filters.incoming & filters.private, group=-5) @@ -62,7 +62,7 @@ async def grp_bd(self: Client, ctx: Message, strings): await ctx.stop_propagation() -@app.on_message(filters.command("banuser", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("banuser", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def ban_a_user(bot, message): if len(message.command) == 1: return await message.reply("Give me a user id / username") @@ -99,7 +99,7 @@ async def ban_a_user(bot, message): ) -@app.on_message(filters.command("unbanuser", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("unbanuser", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def unban_a_user(bot, message): if len(message.command) == 1: return await message.reply("Give me a user id / username") @@ -127,7 +127,7 @@ async def unban_a_user(bot, message): await message.reply(f"Successfully unbanned user {k.mention}!!!") -@app.on_message(filters.command("disablechat", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("disablechat", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def disable_chat(bot, message): if len(message.command) == 1: return await message.reply("Give me a chat id") @@ -166,7 +166,7 @@ async def disable_chat(bot, message): await message.reply(f"Error - {e}") -@app.on_message(filters.command("enablechat", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("enablechat", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def re_enable_chat(_, ctx: Message): if len(ctx.command) == 1: return await ctx.reply("Give me a chat id") diff --git a/misskaty/plugins/blacklist_chat.py b/misskaty/plugins/blacklist_chat.py index 24edfb9acf..ac7a83aba3 100644 --- a/misskaty/plugins/blacklist_chat.py +++ b/misskaty/plugins/blacklist_chat.py @@ -37,7 +37,7 @@ from misskaty import app from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.permissions import adminsOnly, list_admins -from misskaty.vars import SUDO +from misskaty.vars import SUDO, OWNER_ID __MODULE__ = "Blacklist" __HELP__ = """ @@ -98,7 +98,7 @@ async def blacklist_filters_re(self, message): user = message.from_user if not user: return - if user.id in SUDO: + if user.id in SUDO or user.id == OWNER_ID: return list_of_filters = await get_blacklisted_words(chat_id) for word in list_of_filters: diff --git a/misskaty/plugins/broadcast.py b/misskaty/plugins/broadcast.py index c4729d1980..4aed61aac7 100644 --- a/misskaty/plugins/broadcast.py +++ b/misskaty/plugins/broadcast.py @@ -7,11 +7,11 @@ from pyrogram.types import Message from misskaty import DATABASE_URI, app -from misskaty.vars import SUDO +from misskaty.vars import OWNER_ID from utils import broadcast_messages -@app.on_message(filters.command("broadcast") & filters.user(SUDO) & filters.reply) +@app.on_message(filters.command("broadcast") & filters.user(OWNER_ID) & filters.reply) async def broadcast(_, ctx: Message): mongo = AsyncClient(DATABASE_URI) userdb = mongo["MissKatyBot"]["peers"] diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py index e68eed0271..2d7c87f230 100644 --- a/misskaty/plugins/chatbot_ai.py +++ b/misskaty/plugins/chatbot_ai.py @@ -15,7 +15,7 @@ from misskaty import app from misskaty.core import pyro_cooldown from misskaty.helper import check_time_gap, post_to_telegraph, use_chat_lang -from misskaty.vars import COMMAND_HANDLER, GOOGLEAI_KEY, OPENAI_KEY, SUDO +from misskaty.vars import COMMAND_HANDLER, GOOGLEAI_KEY, OPENAI_KEY, OWNER_ID __MODULE__ = "ChatBot" __HELP__ = """ @@ -123,7 +123,7 @@ async def openai_chatbot(self, ctx: Message, strings): return await ctx.reply_msg("OPENAI_KEY env is missing!!!") uid = ctx.from_user.id if ctx.from_user else ctx.sender_chat.id is_in_gap, _ = await check_time_gap(uid) - if is_in_gap and (uid not in SUDO): + if is_in_gap and (uid not == OWNER_ID): return await ctx.reply_msg(strings("dont_spam"), del_in=5) pertanyaan = ctx.input msg = await ctx.reply_msg(strings("find_answers_str"), quote=True) @@ -131,7 +131,7 @@ async def openai_chatbot(self, ctx: Message, strings): gptai_conversations[uid] = [{"role": "system", "content": "Kamu adalah AI dengan karakter mirip kucing bernama MissKaty AI yang diciptakan oleh Yasir untuk membantu manusia mencari informasi."}, {"role": "user", "content": pertanyaan}] else: gptai_conversations[uid].append({"role": "user", "content": pertanyaan}) - ai_response = await get_openai_stream_response(True, OPENAI_KEY, "https://models.inference.ai.azure.com" if uid in SUDO else "https://duckai.yasirapi.eu.org/v1", "gpt-4o" if uid in SUDO else "gpt-4o-mini", gptai_conversations[uid], msg, strings) + ai_response = await get_openai_stream_response(True, OPENAI_KEY, "https://models.inference.ai.azure.com" if uid == OWNER_ID else "https://duckai.yasirapi.eu.org/v1", "gpt-4o" if uid == OWNER_ID else "gpt-4o-mini", gptai_conversations[uid], msg, strings) if not ai_response: gptai_conversations[uid].pop() if len(gptai_conversations[uid]) == 1: diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py index 6feb8ee959..dc9122c436 100644 --- a/misskaty/plugins/dev.py +++ b/misskaty/plugins/dev.py @@ -60,7 +60,7 @@ from misskaty.helper.human_read import get_readable_file_size, get_readable_time from misskaty.helper.localization import use_chat_lang from database.payment_db import autopay_update -from misskaty.vars import AUTO_RESTART, COMMAND_HANDLER, LOG_CHANNEL, SUDO, PAYDISINI_CHANNEL_ID, PAYDISINI_KEY +from misskaty.vars import AUTO_RESTART, COMMAND_HANDLER, LOG_CHANNEL, SUDO, OWNER_ID PAYDISINI_CHANNEL_ID, PAYDISINI_KEY __MODULE__ = "DevCommand" __HELP__ = """ @@ -142,7 +142,7 @@ async def refund_star_payment(client: Client, message: Message): await message.reply_msg(e) -@app.on_message(filters.command(["logs"], COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command(["logs"], COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) @use_chat_lang() async def log_file(_, ctx: Message, strings): """Send log file""" @@ -244,7 +244,7 @@ async def donate(self: Client, ctx: Message): @app.on_message( - filters.command(["balas"], COMMAND_HANDLER) & filters.user(SUDO) & filters.reply + filters.command(["balas"], COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID)) & filters.reply ) async def balas(_, ctx: Message) -> "str": pesan = ctx.input @@ -346,7 +346,7 @@ def draw_progressbar(coordinate, progress): # Gban -@app.on_message(filters.command("gban", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("gban", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def ban_globally(self: Client, ctx: Message): user_id, reason = await extract_user_and_reason(ctx) if not user_id: @@ -364,7 +364,7 @@ async def ban_globally(self: Client, ctx: Message): from_user = ctx.from_user - if user_id in [from_user.id, self.me.id] or user_id in SUDO: + if user_id in [from_user.id, self.me.id] or user_id in SUDO or user_id == OWNER_ID: return await ctx.reply_text("I can't ban that user.") served_chats = await db.get_all_chats() m = await ctx.reply_text( @@ -412,7 +412,7 @@ async def ban_globally(self: Client, ctx: Message): # Ungban -@app.on_message(filters.command("ungban", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("ungban", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) async def unban_globally(_, ctx: Message): user_id = await extract_user(ctx) if not user_id: @@ -434,11 +434,11 @@ async def unban_globally(_, ctx: Message): @app.on_message( - filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(SUDO) + filters.command(["shell", "sh", "term"], COMMAND_HANDLER) & filters.user(OWNER_ID) ) @app.on_edited_message( filters.command(["shell", "sh", "term"], COMMAND_HANDLER) - & filters.user(SUDO) + & filters.user(OWNER_ID) & ~filters.react ) @user.on_message(filters.command(["shell", "sh", "term"], ".") & filters.me) @@ -501,14 +501,14 @@ async def shell_cmd(self: Client, ctx: Message, strings): filters.command(["ev", "run", "myeval"], COMMAND_HANDLER) | filters.regex(r"app.run\(\)$") ) - & filters.user(SUDO) + & filters.user(OWNER_ID) ) @app.on_edited_message( ( filters.command(["ev", "run", "meval"], COMMAND_HANDLER) | filters.regex(r"app.run\(\)$") ) - & filters.user(SUDO) + & filters.user(OWNER_ID) & ~filters.react ) @user.on_message(filters.command(["ev", "run", "meval"], ".") & filters.me) @@ -649,7 +649,7 @@ def _help(*args: Any, **kwargs: Any) -> None: # Update and restart bot -@app.on_message(filters.command(["restart"], COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command(["restart"], COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) @use_chat_lang() async def update_restart(_, ctx: Message, strings): msg = await ctx.reply_msg(strings("up_and_rest")) diff --git a/misskaty/plugins/download_upload.py b/misskaty/plugins/download_upload.py index dd0ac584c9..948715783a 100644 --- a/misskaty/plugins/download_upload.py +++ b/misskaty/plugins/download_upload.py @@ -22,13 +22,13 @@ from misskaty.core.decorator import capture_err, new_task from misskaty.helper.http import fetch from misskaty.helper.pyro_progress import humanbytes, progress_for_pyrogram -from misskaty.vars import COMMAND_HANDLER, SUDO +from misskaty.vars import COMMAND_HANDLER, OWNER_ID LOGGER = getLogger("MissKaty") __MODULE__ = "Download/Upload" __HELP__ = """ -/download [url] - Download file from URL (Sudo Only) +/download [url] - Download file from URL (OWNER Only) /download [reply_to_TG_File] - Download TG File /tgraph_up [reply_to_TG_File] - Download TG File /tiktokdl [link] - Download TikTok Video, try use ytdown command if error. @@ -82,7 +82,7 @@ async def upload(bot, message): os.remove(fileku) -@app.on_message(filters.command(["download"], COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command(["download"], COMMAND_HANDLER) & filters.user(OWNER_ID)) @capture_err @new_task async def download(client, message): diff --git a/misskaty/plugins/federation.py b/misskaty/plugins/federation.py index 8e1476864f..5c932bca84 100644 --- a/misskaty/plugins/federation.py +++ b/misskaty/plugins/federation.py @@ -35,7 +35,7 @@ from misskaty import BOT_ID, app from misskaty.core.decorator.errors import capture_err from misskaty.helper.functions import extract_user, extract_user_and_reason -from misskaty.vars import COMMAND_HANDLER, LOG_GROUP_ID, SUDO +from misskaty.vars import COMMAND_HANDLER, LOG_GROUP_ID, SUDO, OWNER_ID __MODULE__ = "Federation" __HELP__ = """ @@ -115,7 +115,7 @@ async def del_fed(client, message): getinfo = await get_fed_info(is_fed_id) if getinfo is False: return await message.reply_text("This federation does not exist.") - if getinfo["owner_id"] == user.id or user.id not in SUDO: + if getinfo["owner_id"] == user.id or user.id not in SUDO or user.id != OWNER_ID: fed_id = is_fed_id else: return await message.reply_text("Only federation owners can do this!") @@ -298,8 +298,8 @@ async def join_fed(self, message): fed_id = await get_fed_id(int(chat.id)) if ( - user.id in SUDO or member.status != ChatMemberStatus.OWNER - ) and user.id not in SUDO: + user.id in SUDO or user.id == OWNER_ID or member.status != ChatMemberStatus.OWNER + ) and user.id not in SUDO and user.id != OWNER_ID: return await message.reply_text("Only group creators can use this command!") if fed_id: return await message.reply_text("You cannot join two federations from one chat") @@ -347,7 +347,7 @@ async def leave_fed(client, message): fed_info = await get_fed_info(fed_id) member = await app.get_chat_member(chat.id, user.id) - if member.status == ChatMemberStatus.OWNER or user.id in SUDO: + if member.status == ChatMemberStatus.OWNER or user.id in SUDO or user.id == OWNER_ID: if await chat_leave_fed(int(chat.id)) is True: if get_fedlog := fed_info["log_group_id"]: await app.send_message( @@ -388,7 +388,7 @@ async def fed_chat(client, message): fed_owner = info["owner_id"] fed_admins = info["fadmins"] all_admins = [fed_owner] + fed_admins + [int(BOT_ID)] - if user.id not in all_admins and user.id not in SUDO: + if user.id not in all_admins and user.id not in SUDO and user.id != OWNER_ID: return await message.reply_text( "You need to be a Fed Admin to use this command" ) @@ -486,7 +486,7 @@ async def fpromote(client, message): "You need to add a federation to this chat first!" ) - if await is_user_fed_owner(fed_id, user.id) or user.id in SUDO: + if await is_user_fed_owner(fed_id, user.id) or user.id in SUDO or user.id == OWNER_ID: user_id = await extract_user(msg) if user_id is None: @@ -545,7 +545,7 @@ async def fdemote(client, message): "You need to add a federation to this chat first!" ) - if await is_user_fed_owner(fed_id, user.id) or user.id in SUDO: + if await is_user_fed_owner(fed_id, user.id) or user.id in SUDO or user.id == OWNER_ID: user_id = await extract_user(msg) if user_id is None: @@ -586,7 +586,7 @@ async def fban_user(client, message): fed_admins = info["fadmins"] fed_owner = info["owner_id"] all_admins = [fed_owner] + fed_admins + [int(BOT_ID)] - if from_user.id not in all_admins and from_user.id not in SUDO: + if from_user.id not in all_admins and from_user.id not in SUDO and from_user.id != OWNER_ID: return await message.reply_text( "You need to be a Fed Admin to use this command" ) @@ -603,7 +603,7 @@ async def fban_user(client, message): ) if not user_id: return await message.reply_text("I can't find that user.") - if user_id in all_admins or user_id in SUDO: + if user_id in all_admins or user_id in SUDO or user_id == OWNER_ID: return await message.reply_text("I can't ban that user.") check_user = await check_banned_user(fed_id, user_id) if check_user: @@ -685,7 +685,7 @@ async def funban_user(client, message): fed_admins = info["fadmins"] fed_owner = info["owner_id"] all_admins = [fed_owner] + fed_admins + [int(BOT_ID)] - if from_user.id not in all_admins and from_user.id not in SUDO: + if from_user.id not in all_admins and from_user.id not in SUDO or from_user.id != OWNER_ID: return await message.reply_text( "You need to be a Fed Admin to use this command" ) @@ -697,7 +697,7 @@ async def funban_user(client, message): user = await app.get_users(user_id) if not user_id: return await message.reply_text("I can't find that user.") - if user_id in all_admins or user_id in SUDO: + if user_id in all_admins or user_id in SUDO or user_id == OWNER_ID: return await message.reply_text("**How can an admin ever be banned!.**") check_user = await check_banned_user(fed_id, user_id) if not check_user: @@ -815,7 +815,7 @@ async def fbroadcast_message(client, message): fed_owner = info["owner_id"] fed_admins = info["fadmins"] all_admins = [fed_owner] + fed_admins + [int(BOT_ID)] - if from_user.id not in all_admins and from_user.id not in SUDO: + if from_user.id not in all_admins and from_user.id not in SUDO and from_user != OWNER_ID: return await message.reply_text( "You need to be a Fed Admin to use this command" ) diff --git a/misskaty/plugins/fun.py b/misskaty/plugins/fun.py index bf1554a735..6bb1c7bc7c 100644 --- a/misskaty/plugins/fun.py +++ b/misskaty/plugins/fun.py @@ -10,7 +10,7 @@ from misskaty import app, user from misskaty.core.decorator.errors import capture_err from misskaty.helper.localization import use_chat_lang -from misskaty.vars import COMMAND_HANDLER, SUDO +from misskaty.vars import COMMAND_HANDLER, SUDO, OWNER_ID async def draw_meme_text(image_path, text): @@ -197,7 +197,7 @@ async def beriharapan(c, m): await reply.reply(f"{sender_name} memberikan {pesan} pada {reply_name}") -@app.on_message(filters.command("react", COMMAND_HANDLER) & filters.user(SUDO)) +@app.on_message(filters.command("react", COMMAND_HANDLER) & (filters.user(SUDO) | filters.user(OWNER_ID))) @user.on_message(filters.command("react", ".")) async def givereact(c, m): if len(m.command) == 1: diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py index 51d80c49d1..2311975b68 100644 --- a/misskaty/plugins/grup_tools.py +++ b/misskaty/plugins/grup_tools.py @@ -21,7 +21,7 @@ from misskaty import BOT_USERNAME, app from misskaty.core.decorator import asyncify, capture_err from misskaty.helper import fetch, use_chat_lang -from misskaty.vars import COMMAND_HANDLER, SUDO, SUPPORT_CHAT +from misskaty.vars import COMMAND_HANDLER, SUPPORT_CHAT, OWNER_ID from utils import temp LOGGER = getLogger("MissKaty") @@ -105,7 +105,7 @@ async def member_has_joined(c: Client, member: ChatMemberUpdated, strings): if not await is_welcome(member.chat.id): return user = member.new_chat_member.user if member.new_chat_member else member.from_user - if user.id in SUDO: + if user.id == OWNER_ID: await c.send_message( member.chat.id, strings("sudo_join_msg"), @@ -178,7 +178,7 @@ async def welcome_toggle_handler(client, message): ) -@app.on_message(filters.command("leave") & filters.user(SUDO)) +@app.on_message(filters.command("leave") & filters.user(OWNER_ID)) async def leave_a_chat(bot, message): if len(message.command) == 1: return await message.reply("Give me a chat id") @@ -204,7 +204,7 @@ async def leave_a_chat(bot, message): # Not to be used -# @app.on_message(filters.command('invite') & filters.user(SUDO)) +# @app.on_message(filters.command('invite') & filters.user(OWNER_ID)) async def gen_invite(bot, message): if len(message.command) == 1: return await message.reply("Give me a chat id") @@ -266,7 +266,7 @@ async def kickme(_, message): await message.reply(f"ERROR: {err}") -@app.on_message(filters.command("users") & filters.user(SUDO)) +@app.on_message(filters.command("users") & filters.user(OWNER_ID)) async def list_users(_, message): # https://t.me/GetTGLink/4184 msg = await message.reply("Getting List Of Users") @@ -286,7 +286,7 @@ async def list_users(_, message): await msg.delete_msg() -@app.on_message(filters.command("chats") & filters.user(SUDO)) +@app.on_message(filters.command("chats") & filters.user(OWNER_ID)) async def list_chats(_, message): msg = await message.reply("Getting List Of chats") chats = await db.get_all_chats() diff --git a/misskaty/plugins/locks.py b/misskaty/plugins/locks.py index 7ca7c81801..57d2ad2f09 100644 --- a/misskaty/plugins/locks.py +++ b/misskaty/plugins/locks.py @@ -33,7 +33,7 @@ from misskaty.core.decorator.errors import capture_err from misskaty.core.decorator.permissions import adminsOnly, list_admins from misskaty.helper.functions import get_urls_from_text -from misskaty.vars import COMMAND_HANDLER, SUDO +from misskaty.vars import COMMAND_HANDLER, SUDO, OWNER_ID LOGGER = getLogger("MissKaty") @@ -209,7 +209,7 @@ async def url_detector(_, message): if not text or not user: return mods = await list_admins(chat_id) - if user.id in mods or user.id in SUDO: + if user.id in mods or user.id in SUDO or user.id == OWNER_ID: return if get_urls_from_text(text): diff --git a/misskaty/plugins/ytdl_plugins.py b/misskaty/plugins/ytdl_plugins.py index 8a1add49c5..8f837b96f5 100644 --- a/misskaty/plugins/ytdl_plugins.py +++ b/misskaty/plugins/ytdl_plugins.py @@ -28,7 +28,7 @@ from misskaty.core import pyro_cooldown from misskaty.core.decorator import capture_err, new_task from misskaty.helper import fetch, isValidURL, use_chat_lang -from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO +from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL, SUDO, OWNER_ID LOGGER = getLogger("MissKaty") YT_REGEX = r"^(https?://)?(www\.)?(youtube|youtu|youtube-nocookie)\.(com|be)/(watch\?v=|embed/|v/|.+\?v=)?(?P[A-Za-z0-9\-=_]{11})" @@ -198,7 +198,7 @@ async def ytdl_gendl_callback(self: Client, cq: CallbackQuery, strings): return await cq.answer(strings("unauth"), True) except QueryIdInvalid: return - if match[2] in ["mkv", "mp4"] and cq.from_user.id not in SUDO: + if match[2] in ["mkv", "mp4"] and cq.from_user.id not in SUDO and and cq.from_user.id == OWNER_ID: try: return await cq.answer(strings("vip-btn"), True) except QueryIdInvalid: diff --git a/misskaty/vars.py b/misskaty/vars.py index 8b60656b6c..f0437bd6d3 100644 --- a/misskaty/vars.py +++ b/misskaty/vars.py @@ -61,6 +61,7 @@ ).split() } ) +OWNER_ID = int(environ.get("OWNER_ID", 2024984460)) SUPPORT_CHAT = environ.get("SUPPORT_CHAT", "YasirPediaChannel") AUTO_RESTART = environ.get("AUTO_RESTART", False) OPENAI_KEY = environ.get("OPENAI_KEY")