From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.226]) by gnuweeb.org (Postfix) with ESMTPSA id C765080958; Thu, 11 Aug 2022 08:27:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1660206466; bh=v6Szn4aJSRmS/3SzfQJQTr0K4OY8MfY5ZY1MTNdx/JQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H5EaSOvXWDl7qcoIQ+YPFZtaD5SFp8HY5wjDcGTBytYAeWVomZpm7lhRqihHjVMxf BpgCHpIqsIOokaPne0luSXl58B9+9nOBtyuW3/5Tf55QTMAk6upc+z3hdNArarZUi7 Y//NHZkdQZ6wNJChARtPItAjA2Sd8GkAaD/Pfb63i3N+/RUGRDSESSb6SGzgUR4VZX MMnfO6SpyUsI5WyvDyRN8PhuuBYs650WehRJC+0C6oBnWEqdtoUkBzRX1t27oqMZ1R vF8wgLkSMYTrEum7YY9W2M+LNT1T8rTTfkQ9mTzWRrRPKcmJQJf5T84UaLAWGg4YQD MeJ+YV/oTHQ3g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List , Alviro Iskandar Setiawan Subject: [PATCH v1 3/4] Use created filter for admin-only Date: Thu, 11 Aug 2022 15:26:55 +0700 Message-Id: <20220811082656.1420-4-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220811082656.1420-1-kiizuha@gnuweeb.org> References: <20220811082656.1420-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Use created filter into the command and callback plugins, which is only admins can use the callback buttons and bot commands. Signed-off-by: Muhammad Rizki --- daemon/packages/plugins/callbacks/del_atom.py | 3 ++- daemon/packages/plugins/callbacks/del_chat.py | 3 ++- daemon/packages/plugins/commands/debugger.py | 4 +++- daemon/packages/plugins/commands/manage_atom.py | 6 ++++-- daemon/packages/plugins/commands/manage_broadcast.py | 5 +++-- daemon/packages/plugins/commands/scrape.py | 3 ++- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/daemon/packages/plugins/callbacks/del_atom.py b/daemon/packages/plugins/callbacks/del_atom.py index 0595e67..1510d60 100644 --- a/daemon/packages/plugins/callbacks/del_atom.py +++ b/daemon/packages/plugins/callbacks/del_atom.py @@ -6,9 +6,10 @@ from packages import DaemonClient from scraper import utils from pyrogram.types import CallbackQuery +import config -@DaemonClient.on_callback_query(group=1) +@DaemonClient.on_callback_query(config.admin_only, group=1) async def on_del_atom(c: DaemonClient, cb: CallbackQuery): if not "del_atom" in cb.data: return diff --git a/daemon/packages/plugins/callbacks/del_chat.py b/daemon/packages/plugins/callbacks/del_chat.py index 54545af..26c6dd8 100644 --- a/daemon/packages/plugins/callbacks/del_chat.py +++ b/daemon/packages/plugins/callbacks/del_chat.py @@ -6,9 +6,10 @@ from packages import DaemonClient from scraper import utils from pyrogram.types import CallbackQuery +import config -@DaemonClient.on_callback_query(group=2) +@DaemonClient.on_callback_query(config.admin_only, group=2) async def on_del_chat(c: DaemonClient, cb: CallbackQuery): if not "del_chat" in cb.data: return diff --git a/daemon/packages/plugins/commands/debugger.py b/daemon/packages/plugins/commands/debugger.py index e0f145e..ae2d31d 100644 --- a/daemon/packages/plugins/commands/debugger.py +++ b/daemon/packages/plugins/commands/debugger.py @@ -7,10 +7,12 @@ from pyrogram import Client, filters, enums from pyrogram.types import Message from textwrap import indent import io, import_expression, contextlib, traceback +import config + @Client.on_message( filters.command(['d','debug']) & - filters.user(["nekoha", "kiizuah"]) + config.admin_only ) async def execute_v2(c: Client, m: Message): sep = m.text.split('\n') diff --git a/daemon/packages/plugins/commands/manage_atom.py b/daemon/packages/plugins/commands/manage_atom.py index 387c70c..3dcd616 100644 --- a/daemon/packages/plugins/commands/manage_atom.py +++ b/daemon/packages/plugins/commands/manage_atom.py @@ -7,10 +7,12 @@ from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton from pyrogram import filters from packages import DaemonClient from scraper import utils +import config + @DaemonClient.on_message( filters.command("add_atom") & - filters.chat(["kiizuah", "nekoha", -1001673279485]) + config.admin_only ) async def add_atom_url(c: DaemonClient, m: Message): if len(m.command) <= 1: @@ -32,7 +34,7 @@ async def add_atom_url(c: DaemonClient, m: Message): @DaemonClient.on_message( filters.command("del_atom") & - filters.chat(["kiizuah", "nekoha", -1001673279485]) + config.admin_only ) async def del_atom_url(c: DaemonClient, m: Message): atoms = c.db.get_atom_urls() diff --git a/daemon/packages/plugins/commands/manage_broadcast.py b/daemon/packages/plugins/commands/manage_broadcast.py index 3f9154c..ffb5a6b 100644 --- a/daemon/packages/plugins/commands/manage_broadcast.py +++ b/daemon/packages/plugins/commands/manage_broadcast.py @@ -7,11 +7,12 @@ from pyrogram.types import Message from pyrogram import filters, enums from packages import DaemonClient from scraper import utils +import config @DaemonClient.on_message( filters.command("add_bc") & - (filters.private | filters.group) + config.admin_only ) async def add_broadcast(c: DaemonClient, m: Message): if m.chat.type == enums.ChatType.PRIVATE: @@ -38,7 +39,7 @@ async def add_broadcast(c: DaemonClient, m: Message): @DaemonClient.on_message( filters.command("del_bc") & - filters.chat(["kiizuah", "nekoha", -1001673279485]) + config.admin_only ) async def del_broadcast(c: DaemonClient, m: Message): if "--list" in m.text: diff --git a/daemon/packages/plugins/commands/scrape.py b/daemon/packages/plugins/commands/scrape.py index 280c3f9..45b1581 100644 --- a/daemon/packages/plugins/commands/scrape.py +++ b/daemon/packages/plugins/commands/scrape.py @@ -9,6 +9,7 @@ from pyrogram import filters from packages import DaemonClient from scraper import Scraper from scraper import utils +import config import shutil import re import asyncio @@ -23,7 +24,7 @@ import asyncio LORE_CMD_URL_PATTERN = r"^(?:\/|\.|\!)lore\s+(https?:\/\/lore\.kernel\.org\/\S+)" @DaemonClient.on_message( filters.regex(LORE_CMD_URL_PATTERN) & - filters.chat(["kiizuah", "nekoha", -1001673279485]) + config.admin_only ) async def scrap_email(c: DaemonClient, m: Message): p = re.search(LORE_CMD_URL_PATTERN, m.text) -- Muhammad Rizki