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 7F72D7E257; Mon, 3 Oct 2022 23:52:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1664841167; bh=5brvxHYcrSzM3FzKxmi+ZivmJtRbjdxc9bbY0Y3rTMw=; h=From:To:Cc:Subject:Date:From; b=M+z/3+5RTNJmcphdqBI/5ujycqkWYOnMTOhEZcfYF0BeyG9miIk8xO4IvM/Wvzjm3 J6djyFJfulMdgcsS3sQu2Lnl6MW8cccS0AJV1C+r/pFQfwLlImjnvTt4cEO5+Sr9I7 Uhftt1BxDYtlb9u85XODMBZHi/fxwLTHUhq/SZ5L3B/CLk8m39LLJ5WTR7Jt4nosCs b5ccsQZB1BAYThE1Fnai8q4+ZzttgWzSS8bSM32ciklHGo6TqE7me6ygxHCfIRFiXR GKawGsTy8H+hu2AqBLdlU/QpmNO4+eqPskSWlUvNu8Wp1l80HTEbfpKBHm+u/0MdTD HIs7o2afD+pMg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 00/28] The complete version of the Discord bot Date: Tue, 4 Oct 2022 06:52:01 +0700 Message-Id: <20221003235230.1824-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. Features: 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. Add broadcast manager slash commands. Add a button UI to go direct to its lore email message. And others. Bugs: 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. Fix the empty temporary patch directory and patch directory deletion after send patch files. Small changes: Rename some utility functions to make it simple and readable. Some changes on the on_ready event give a tip message on what to do when the bot first starts. There are 28 patches in this series: - Patch 1 is to add .gitignore file to ignore all patch directories - Patch 2 is to add a platform parameter func for the storage management - Patch 3 is to move the gen_temp() code when its necessary to call - Patch 4 is to add get_atom_urls() to get the list of atom URLs in the DB - Patch 5 is to add get_broadcast_chats() to get the list of Discord ch - Patch 6 is to add get_email_id() to get the email ID of the PK emails - Patch 7 is to add get_reply_id() to get the Discord message ID - Patch 8 is to inherit Getter() to the DBMethods() class - Patch 9 is to add delet_atom() to delete specific atom URL - Patch 10 is to add delete_broadcast() to delete current Discord channel - Patch 11 is to inherit Deletion() to the DBMethods() class - Patch 12 is to inherit DBMethods() to the DB() class - Patch 13 is to implement the created DB() class in the GWClient() class - Patch 14 is to rename some utility functions - Patch 15 is to add a FullMessageBtn() button URL class to go to the lore - Patch 16 is to add a @filters.wait_on_limit() to handle the rate limit - Patch 17 is to add send lore email message functions - Patch 18 is to add a mail listener to get the new lore email message - Patch 19 is to implement the mail Listener() class in the dc.py - Patch 20 is to add a @filters.lore_admin() to filter only the lore admin - Patch 21 is to add a `/atom list` slash command - Patch 22 is to add a `/atom add` slash command - Patch 23 is to add a `/atom delete` slash command - Patch 24 is to add a channel_link() util function in the atom/utils.py - Patch 25 is to add a `/broadcast list` slash command - Patch 26 is to add a `/broadcast add` slash command - Patch 27 is to add a `/broadcast delete` slash command - Patch 28 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 works fine. But, this PATCH series just only for Discord bot first. Then, I will fix the same issue for the Telegram bot, thanks. ## Changelog v1 -> v2 - Add .gitignore in the Discord's storage directory - Fix the empty patch directory - Fix the patch directory removal after send patch files, see commit 18/28 Muhammad Rizki (28): discord: Add .gitignore in the Discord's storage directory Fix the storage management after the refactor was happened Fix the empty temporary patch directory on atom/utils.py discord: Add get_atom_urls() to get the list of atom URLs 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 | 153 ++++++++++++++++++ daemon/dscord/storage/.gitignore | 2 + daemon/telegram/mailer/listener.py | 2 +- daemon/telegram/packages/client.py | 6 +- 26 files changed, 771 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 create mode 100644 daemon/dscord/storage/.gitignore base-commit: fdbccda0372a7869b7ac6b8c5b31ec1761b5e084 -- Muhammad Rizki