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 AC7CE804FD; Sat, 1 Oct 2022 13:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664629513; bh=GfiYUMEHEJtu1oN5OpF17au9ISaabCFH9QWpr8FSack=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OD1/WBZkbJFsvCaartnB54qQcabo4qncejYq5GmT10m2Fve47TF1OttB/+r2gd+7d zS0hZ3kBAhaMiJ5m87D6Mhg1SD6BryOcMnICU5byBu+UFVIXrKTEz/kPYsRTMnZ+ss BARFlZL5nyzQA4ZbbVmjLFjpij8DTG5g5Rf9aHXO4oXOFSe9ODKXquiVR/4EaxfQwQ yv8t0wdmfvhSgTiEiMfCY2P1WBvddQ3E6bNK2C+j+9erEkfyfLTCFbeiAZ/pDCL8GD sWaNxs0eASvgAXkSY3OKKtcEy8RxXrOvzqzeVvQMtxiP1+8qP56b6J9w8e29OtdsXC 9wclwI+bl7Q0A== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 23/26] discord: Add a list broadcast slash command Date: Sat, 1 Oct 2022 20:03:51 +0700 Message-Id: <20221001130355.784-24-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 `/broadcast list` slash command to get the list of the current Discord channel listening for a new lore email message. Signed-off-by: Muhammad Rizki --- .../plugins/slash_commands/__init__.py | 2 + .../slash_commands/manage_broadcast.py | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 daemon/dscord/gnuweeb/plugins/slash_commands/manage_broadcast.py diff --git a/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py b/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py index 0ed86b1..a6d913c 100644 --- a/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py +++ b/daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py @@ -4,8 +4,10 @@ # from .manage_atom import ManageAtomSC +from .manage_broadcast import ManageBroadcastSC class SlashCommands( ManageAtomSC, + ManageBroadcastSC ): pass diff --git a/daemon/dscord/gnuweeb/plugins/slash_commands/manage_broadcast.py b/daemon/dscord/gnuweeb/plugins/slash_commands/manage_broadcast.py new file mode 100644 index 0000000..db3d9e6 --- /dev/null +++ b/daemon/dscord/gnuweeb/plugins/slash_commands/manage_broadcast.py @@ -0,0 +1,41 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Copyright (C) 2022 Muhammad Rizki +# + +from discord.ext import commands +from discord import Interaction +from discord import app_commands + +from dscord.gnuweeb import filters + + +class ManageBroadcastSC(commands.Cog): + broadcast = app_commands.Group( + name="broadcast", + description="Manage broadcast channel." + ) + + + def __init__(self, bot) -> None: + self.bot = bot + + + @broadcast.command( + name="list", + description="List of broadcast channel." + ) + @filters.lore_admin + async def list_channel(self, i: "Interaction"): + chats = self.bot.db.get_broadcast_chats() + if len(chats) == 0: + t = "Currently empty." + await i.response.send_message(t, ephemeral=True) + return + + text = "List of channels that will send email messages:\n" + for u,n in zip(chats, range(1, len(chats)+1)): + text += f"{n}. **{u[3]}**\n" + text += f"Link: {u[4]}\n\n" + + await i.response.send_message(text, ephemeral=True) -- Muhammad Rizki