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 1E0437E328; Fri, 29 Jul 2022 00:46:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1659055572; bh=CYBmVIoSkdpKxd53Jz325qzOeFHq8wNWO8yqj2xO8Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J8B2AsKmLS0U2wZ9HaHD1mGK4naPYXDqxlzFEKAw9I1gPvRT8teaW4smTKunoJIBB aTPk+uZqAQ7VzPpBqTg/c+biefv7iUDl0TsDRQRvzZmIVlS3ajAk1f+XuwAqTk0uf0 FJBLNrtAwlWXavtxdy8ppllj4whdoDqBaT3NyTfnUBpbCunRBgtkuqYISRP4ZBwpfX MKva4V+WUQbNTz/lMkxSPreuXKP3mfSFQax0mApxsuCT1JHa66fLw5fNTHFpkc7xQP Hl5dgv2SQpjvZ2xzjPpepF5X6dsaHG6Q+Nmr4vk9HhpCMECa5cfQf7b/EuUTRc1l0Z 4bwqCVtKw5OUg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: [PATCH v2 17/18] Add /del_bc bot command Date: Fri, 29 Jul 2022 07:45:06 +0700 Message-Id: <20220729004507.1668-18-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: Add /del_bc bot command for manage delete chat from receiving email message. Signed-off-by: Muhammad Rizki --- .../plugins/commands/manage_broadcast.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/daemon/packages/plugins/commands/manage_broadcast.py b/daemon/packages/plugins/commands/manage_broadcast.py index e0cc0dc..b13d6ce 100644 --- a/daemon/packages/plugins/commands/manage_broadcast.py +++ b/daemon/packages/plugins/commands/manage_broadcast.py @@ -34,3 +34,33 @@ async def add_broadcast(c: DaemonClient, m: Message): msg = f"Success add this chat for receiving email messages" await m.reply(msg) + + +@DaemonClient.on_message( + filters.command("del_bc") & + filters.chat(["kiizuah", "nekoha", -1001673279485]) +) +async def del_broadcast(c: DaemonClient, m: Message): + if "--list" in m.text: + chats = c.db.get_broadcast_chats() + if len(chats) == 0: + return await m.reply("Currently empty.") + + text = "List of chats that will receive email message:\n" + for u,i in zip(chats, range(1, len(chats)+1)): + text += f"{i}. **[{u[3]}]({u[5]})**\n" + + text += "\nChoose one of the chat above to delete by index below." + return await m.reply(text, reply_markup=utils.button_numbers( + data=chats, + callback_prefix="del_chat" + )) + + success = c.db.delete_broadcast(m.chat.id) + if not success: + msg = "Failed to delete this chat from receiving email message\n" + msg += "Maybe it's already been deleted or not exists." + else: + msg = "Success delete this chat from receiving email message" + + await m.reply(msg) -- Muhammad Rizki