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.217]) by gnuweeb.org (Postfix) with ESMTPSA id 637018108B; Mon, 3 Oct 2022 23:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664841223; bh=2iHMLFAXZzdxEGwcgju+XoQlJ3kNhBjssxZy2bcb64U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l8/PwCVgkG+2s/auf2wMzgc7Uclm35PwCr/u+Hkoq/Cu3PiU6BspONkTygl6urWYa FDumhkbHquJqpQDZ4ASZN0lFHz4v3vaG/7sBBlIRgKWxVvAHjms00lMdpTSp5FOzT8 L7MlVuidWPR9F+4MxoMRL1LEKHfVKBxx+8VJ/ZpUYvOkUNmgkS6WzFFFnmj8hT9RUj msxcqMOiNfxC/SuZPNM15czQlCWjvx0IbojKAIXL48i58c9rc/HAtoBRNZlE48sqVO gjlrOQSpTqlowykQy5bt+49ASH7Doow/xKoMsaJTc7YuBML2+V4yE6EZZmjP9tN1gG bTKS9nIgAdeoA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 22/28] discord: Add an add atom slash command Date: Tue, 4 Oct 2022 06:52:23 +0700 Message-Id: <20221003235230.1824-23-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221003235230.1824-1-kiizuha@gnuweeb.org> References: <20221003235230.1824-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add `/add atom` to add an atom URL to the database for listening to a new lore email message. Signed-off-by: Muhammad Rizki --- .../plugins/slash_commands/manage_atom.py | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/daemon/dscord/gnuweeb/plugins/slash_commands/manage_atom.py b/daemon/dscord/gnuweeb/plugins/slash_commands/manage_atom.py index a4281c1..409e612 100644 --- a/daemon/dscord/gnuweeb/plugins/slash_commands/manage_atom.py +++ b/daemon/dscord/gnuweeb/plugins/slash_commands/manage_atom.py @@ -7,6 +7,7 @@ from discord.ext import commands from discord import Interaction from discord import app_commands +from atom import utils from dscord.gnuweeb import filters @@ -37,3 +38,26 @@ class ManageAtomSC(commands.Cog): text += f"{n}. {u}\n" await i.response.send_message(text, ephemeral=True) + + + @atom.command( + name="add", + description="Add lore atom URL for receiving lore emails." + ) + @app_commands.describe(url='Lore atom URL.') + @filters.lore_admin + async def add_atom(self, i: "Interaction", url: str): + is_atom = await utils.is_atom_url(url) + if not is_atom: + t = "Invalid Atom URL." + await i.response.send_message(t, ephemeral=True) + return + + inserted = self.bot.db.save_atom(url) + if inserted is None: + t = f"This URL already listened for new email." + await i.response.send_message(t, ephemeral=True) + return + + t = f"Success add **{url}** for listening new email." + await i.response.send_message(t, ephemeral=True) -- Muhammad Rizki