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 A4078804FD; Sat, 1 Oct 2022 13:04:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664629454; bh=zXK73KOpu+OotHcFovWTGkuI1qkXxn0yd7oEb09Ns7w=; h=From:To:Cc:Subject:Date:From; b=Xr/SnrAObOuEdRuDLY9xACyTSPmzZt0Yjn7nZmjUR4Bsa92QEPHgKJcPdIqKwgAm0 24X0yAiOcKhB1elhvQtV341JkFUqzNHUFnE3pmGZNoaG8TmK1mSCoefpFVNDy/YFs1 XU19pDsk5fcZP0ssdK5FtYwQqVV6wqh0G1n6GNJHohJttjtJa8RvuI34J8Y3hU90FH Nu9kGODEInavKASGpYESVSB9ZUtNTQ0PKVGeYvCaPm4vZ2iP9oHsefKzOQyP+on8Y5 R/fVGmx2VLuwjDLn7wdNT3hD5xDTs5U+WHU5jLCZgIVF57D1oQzVdBvTGvz6ufmRdd VfqmDTU3wM83g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 00/26] The complete version of the Discord bot Date: Sat, 1 Oct 2022 20:03:28 +0700 Message-Id: <20221001130355.784-1-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Hi, sir In this series, I create the complete version of the Discord bot. This series contains slash commands, events, and basic commands for syncing the slash commands to the global. Add getter and deletion database methods. Add a mail listener to get the new lore email message. Add filters to only the lore admin who can use the atom and broadcast manager slash commands. This series contains fix a bug in the storage management on the atom/utils.py, because I forgot to test the Telegram bot in the past. Rename some utility functions to make it simple and readable. Add a button UI to go direct to its lore email message. Some changes on the on_ready event give a tip message on what to do when the bot first starts. There are 26 patches in this series: - Patch 1 is to add get_atom_urls() to get the list of atom URLs in the DB - Patch 2 is to fix the storage management on the atom/utils.py - Patch 3 is to add get_broadcast_chats() to get the list of Discord ch - Patch 4 is to add get_email_id() to get the email ID of the PK emails - Patch 5 is to add get_reply_id() to get the Discord message ID - Patch 6 is to inherit Getter() to the DBMethods() class - Patch 7 is to add delet_atom() to delete specific atom URL - Patch 8 is to add delete_broadcast() to delete current Discord channel - Patch 9 is to inherit Deletion() to the DBMethods() class - Patch 10 is to inherit DBMethods() to the DB() class - Patch 11 is to implement the created DB() class in the GWClient() class - Patch 12 is to rename some utility functions - Patch 13 is to add a FullMessageBtn() button URL class to go to the lore - Patch 14 is to add a @filters.wait_on_limit() to handle the rate limit - Patch 15 is to add send lore email message functions - Patch 16 is to add a mail listener to get the new lore email message - Patch 17 is to implement the mail Listener() class in the dc.py - Patch 18 is to add a @filters.lore_admin() to filter only the lore admin - Patch 19 is to add a `/atom list` slash command - Patch 20 is to add a `/atom add` slash command - Patch 21 is to add a `/atom delete` slash command - Patch 22 is to add a channel_link() util function in the atom/utils.py - Patch 23 is to add a `/broadcast list` slash command - Patch 24 is to add a `/broadcast add` slash command - Patch 25 is to add a `/broadcast delete` slash command - Patch 26 is to add a tip message on the on_ready event How to use: 1. Execute the db.sql file in the daemon directory, 2. Setup .env file, the example is there with suffix .example, this file name must remove the suffix name .example, 3. Set up the config.py in each bot directory, such as dscord and telegram. The example is there with suffix .example & the file name must remove suffix name .example, 4. Run `pip3 install -r requirements.txt` in each bot directory, 5. STORAGE_DIR env value must `storage` to make it work fine, 6. Run the bot by `python3 dc.py` or `python3 tg.py`. Both tested and worked fine. Please give it a test if I still forgot something like in the past, thanks! Muhammad Rizki (26): discord: Add get_atom_urls() to get the list of atom URLs Fix the storage management after the refactor was happened discord: Add get_broadcast_chats() to get the list of broadcast chats discord: Add get_email_id() in getter directory discord: Add get_reply_id() in getter directory discord: Inherit Getter() class to the DBMethods() class discord: Add delete_atom() in deletion directory discord: Add delete_broadcast() in deletion directory discord: Inherit the Deletion() class to the DBMethods() class discord: Inherit the DBMethods() class to the DB() class discord: Use the created DB() class telegram: Rename some utility functions discord: Add a FullMessageBtn() class in models discord: Add filters.wait_on_limit() decorator discord: Add send lore email message functions discord: Add mail listener discord: Implement the mail Listener() class discord: Add @filters.lore_admin() decorator discord: Add a list of atom URL slash command discord: Add an add atom slash command discord: Add a delete atom slash command discord: Add channel_link() in the atom/utils.py discord: Add a list broadcast slash command discord: Add an add broadcast slash command discord: Add a delete broadcast slash command discord: Change the on_ready message daemon/atom/utils.py | 81 ++++++--- daemon/dc.py | 30 +++- daemon/dscord/database/core.py | 5 +- daemon/dscord/database/methods/__init__.py | 6 +- .../database/methods/deletion/__init__.py | 14 ++ .../database/methods/deletion/delete_atom.py | 15 ++ .../methods/deletion/delete_broadcast.py | 15 ++ .../database/methods/getter/__init__.py | 18 ++ .../database/methods/getter/get_atom_urls.py | 21 +++ .../methods/getter/get_broadcast_chats.py | 21 +++ .../database/methods/getter/get_email_id.py | 60 +++++++ .../database/methods/getter/get_reply.py | 33 ++++ daemon/dscord/gnuweeb/client.py | 52 +++++- daemon/dscord/gnuweeb/filters.py | 53 ++++++ daemon/dscord/gnuweeb/models/__init__.py | 6 + .../dscord/gnuweeb/models/full_message_btn.py | 12 ++ daemon/dscord/gnuweeb/plugins/__init__.py | 4 +- .../dscord/gnuweeb/plugins/events/on_ready.py | 7 +- .../plugins/slash_commands/__init__.py | 13 ++ .../plugins/slash_commands/manage_atom.py | 81 +++++++++ .../slash_commands/manage_broadcast.py | 84 ++++++++++ daemon/dscord/mailer/__init__.py | 7 + daemon/dscord/mailer/listener.py | 154 ++++++++++++++++++ daemon/telegram/mailer/listener.py | 2 +- daemon/telegram/packages/client.py | 6 +- 25 files changed, 770 insertions(+), 30 deletions(-) create mode 100644 daemon/dscord/database/methods/deletion/__init__.py create mode 100644 daemon/dscord/database/methods/deletion/delete_atom.py create mode 100644 daemon/dscord/database/methods/deletion/delete_broadcast.py create mode 100644 daemon/dscord/database/methods/getter/__init__.py create mode 100644 daemon/dscord/database/methods/getter/get_atom_urls.py create mode 100644 daemon/dscord/database/methods/getter/get_broadcast_chats.py create mode 100644 daemon/dscord/database/methods/getter/get_email_id.py create mode 100644 daemon/dscord/database/methods/getter/get_reply.py create mode 100644 daemon/dscord/gnuweeb/filters.py create mode 100644 daemon/dscord/gnuweeb/models/__init__.py create mode 100644 daemon/dscord/gnuweeb/models/full_message_btn.py create mode 100644 daemon/dscord/gnuweeb/plugins/slash_commands/__init__.py create mode 100644 daemon/dscord/gnuweeb/plugins/slash_commands/manage_atom.py create mode 100644 daemon/dscord/gnuweeb/plugins/slash_commands/manage_broadcast.py create mode 100644 daemon/dscord/mailer/__init__.py create mode 100644 daemon/dscord/mailer/listener.py base-commit: fdbccda0372a7869b7ac6b8c5b31ec1761b5e084 -- Muhammad Rizki