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.177]) by gnuweeb.org (Postfix) with ESMTPSA id E4C9C80FBA; Sat, 1 Oct 2022 13:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664629505; bh=2iHMLFAXZzdxEGwcgju+XoQlJ3kNhBjssxZy2bcb64U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NsCHEQBUIvF1pwcOPbtclgvMPCp8Tm6+9S2TfrCTXpU+ej3ctMvLpyJx0rOeEkYZZ 4yOz7f255c6bIr2e8nWvA1Sbq0ZX03a176rRo9pftDtoexgdfEdHrmCR292/r1BYPc a22AVn4JY8kGxclUhRP3EYBM14qwnERFQhSEJvgpVMKMJhmQkTv9aDEvXqWCruqiqI UIOATEqmzw33ww6AUwjiXVfc0pt91ZEEsC0bdg7zU72l8wMZrpA6mEfCDrI0ReOQsA JOdwlqY6g2tIGHcTKf7xyRDskQAwChIkXt/6GfvC1j7Q1bm3xGsbt83eIpFufFxG0E L559HRSmzH82w== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 20/26] discord: Add an add atom slash command Date: Sat, 1 Oct 2022 20:03:48 +0700 Message-Id: <20221001130355.784-21-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221001130355.784-1-kiizuha@gnuweeb.org> References: <20221001130355.784-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