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.94]) by gnuweeb.org (Postfix) with ESMTPSA id 4632D7E328; Fri, 29 Jul 2022 00:46:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1659055561; bh=sBRHXjDmmroNyMRlKL0G7FhlyEv9ORKbxvO4tqNSpqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JBqGfe5iRBi3XhaKH3xxwwfjPGuXiemkoqvHnDaiy9r+0rGGBBxhtscsZXRsC7HHv R7Xy1ZrcrXQkk1LxagDBfxo1BUAII9rA1d/Im8q+kbLKX445M+II2kgiTcoSYY83bU pUeLki2au5q/CbS+xqzQBXQXCjDzjTWt933JcYdvxI5DUkwWhEUmpJT52HEKyhQlP1 FdGBdx9AQHt67SiaNa6WfRpVbeuv0Ckz4LkiPO5579PxqkO+/wk3UfW7XRHZDAd26p OsS+fyHuGUsf6Eoo2EGBuKV+ciXqOQyQ0NcPha4neADWumY0+N50l7qTNWL6Wcf1qw 8bncGgewDFrhw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH v2 12/18] Add del_atom callback query Date: Fri, 29 Jul 2022 07:45:01 +0700 Message-Id: <20220729004507.1668-13-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220729004507.1668-1-kiizuha@gnuweeb.org> References: <20220729004507.1668-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: I want to easily remove atom URL by index remotely using bot message button, easily just press the button number in /del_atom bot command. Signed-off-by: Muhammad Rizki --- daemon/packages/plugins/callbacks/del_atom.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 daemon/packages/plugins/callbacks/del_atom.py diff --git a/daemon/packages/plugins/callbacks/del_atom.py b/daemon/packages/plugins/callbacks/del_atom.py new file mode 100644 index 0000000..0595e67 --- /dev/null +++ b/daemon/packages/plugins/callbacks/del_atom.py @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2022 Muhammad Rizki +# + +from packages import DaemonClient +from scraper import utils +from pyrogram.types import CallbackQuery + + +@DaemonClient.on_callback_query(group=1) +async def on_del_atom(c: DaemonClient, cb: CallbackQuery): + if not "del_atom" in cb.data: + return + + atoms = c.db.get_atom_urls() + if len(atoms) == 0: + return await cb.answer("Currently empty.") + + index = int(utils.remove_command(cb.data)) + atom = atoms[index - 1] + c.db.delete_atom(atom) + + await cb.answer( + f"Success delete {atom} from listening new email", + show_alert=True + ) + + await cb.message.delete() + if cb.message.reply_to_message: + await cb.message.reply_to_message.delete() -- Muhammad Rizki