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 E530C7E24B; Mon, 1 Aug 2022 00:20:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1659313219; bh=diZcWTWY9fkQB/vDAzjUX0ElMGGpEPMkopBiYt/ZkN8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SdNBL/Gi+X5mKkZVzbfhM/XOWMxp2oah8RzwZkr2geDyDND67QFAzibL1sA/aqlJ+ zUBlb4s6ds+s5NytwULGZwRsDMl5+t8DNEBmhSofbDFjeg73zxk5Y20vSq+bqoPmzh bmU9OarpjPfacY8B/eijQ3x6ilMaL+6mpyFCbs2wetB0W+YgPGdSMz73YailIjZiFz s9G2iHKGavCK6jIqiAZWDoPfLH5QWqRQXxR3hyPrytWIeFqL06iVpnoX32Gi4Wbv6Q ee9neoGcFtA7ZInxWseojVjXhY+0AZoR/LOndL37jh3v35BwU0Xf8kt5jaxuU18SBb JX3WAx6KsAlUQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List , Alviro Iskandar Setiawan Subject: [PATCH v5 18/19] Add /del_bc bot command Date: Mon, 1 Aug 2022 07:19:16 +0700 Message-Id: <20220801001917.992-19-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220801001917.992-1-kiizuha@gnuweeb.org> References: <20220801001917.992-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 | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/daemon/packages/plugins/commands/manage_broadcast.py b/daemon/packages/plugins/commands/manage_broadcast.py index e0cc0dc..a518808 100644 --- a/daemon/packages/plugins/commands/manage_broadcast.py +++ b/daemon/packages/plugins/commands/manage_broadcast.py @@ -34,3 +34,37 @@ 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=text, + disable_web_page_preview=True, + 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