public inbox for [email protected]
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>
Subject: [PATCH v1 3/4] Use created filter for admin-only
Date: Thu, 11 Aug 2022 15:26:55 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

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 <[email protected]>
---
 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
 
 
[email protected]_callback_query(group=1)
[email protected]_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
 
 
[email protected]_callback_query(group=2)
[email protected]_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


  parent reply	other threads:[~2022-08-11  8:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11  8:26 [PATCH v1 0/4] Add admin configuration Muhammad Rizki
2022-08-11  8:26 ` [PATCH v1 1/4] Add config.py.example Muhammad Rizki
2022-08-11  8:26 ` [PATCH v1 2/4] Add config.py in .gitignore Muhammad Rizki
2022-08-11  8:26 ` Muhammad Rizki [this message]
2022-08-11  8:26 ` [PATCH v1 4/4] Remove unused codes in some files Muhammad Rizki
2022-08-11 22:29 ` [PATCH v1 0/4] Add admin configuration Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox