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 52A03806F8; Fri, 29 Jul 2022 00:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1659055357; bh=CYBmVIoSkdpKxd53Jz325qzOeFHq8wNWO8yqj2xO8Dg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Swx7MUdNoEMtWq6/+hVa0yVgb+za7yltRZuwjAlaUnAHir5KOFZbKdlWzZXmFPNfg lHsig4umoeSa+V6QBqjbPIrAgRpxqt/uRxoR3gBVjjBDFhIoo8+Zjj1W9+tpmi8hBL Eqxt0XsRRLoUCKfYDnla+z9kRJCe9aZcWU5AVZNXg3uv05yBo/b5FwI+yC34q0f2Fo g17yu9MDRLuSOuQR6nZrjPkvjXUJiquFKP0suFcdeV9cNl/r55xmwHMwPJ8cq5JRhG aHnyttzkBw0CwcxYd/xOippmTMqK9l8FIoBLkJWUMSELW9+BOdmLMScOjMKNYZqg7K SVnggTJwdLG/w== 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:40:45 +0700 Message-Id: <20220729004046.1890-37-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220729004046.1890-1-kiizuha@gnuweeb.org> References: <20220729004046.1890-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