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.100]) by gnuweeb.org (Postfix) with ESMTPSA id 47CAF7E257; Tue, 6 Sep 2022 11:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662463188; bh=EnaBHOUfaaDYWkuofFnKDp42koAAspLOOeAVuaEUjMQ=; h=From:To:Cc:Subject:Date:From; b=rRmJjOLINrh+moN3LtzP3qAXHpqJRNYyw3DpYNUGq8tXVMar4vFAQnb11CQOVoHaw M7sEbqGVuDO6dzavQHZTXzz5bNah94QELz6s5MxwpMqWAcvjTv8ohDGxuwIj6w3nXG njbBvTW+1Elz3v+FAJf3wjBVoqvtFsd+TrFCaEOvFlQkKmrD9vLlAJfcFDbRyguyet SsnvtK0NWQtu0Y2CwHAmwa69vhCmVvWzez2R63Kba2QtAEus1dWJ8MIDqGk6EK2rMv eeyldetMq731pvnHWZAgqHA3qfOSYbyNIZds2mUyDmk4uMtzSLRO+kw4kbhzQht3Fq dSc+jjBfzCxQg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List , Alviro Iskandar Setiawan Subject: [RFC PATCH v1 0/5] Refactor some Telegram bot source code Date: Tue, 6 Sep 2022 18:19:24 +0700 Message-Id: <20220906111929.1657-1-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Afternoon sir, I just want to ask if this series okay to review or not? These series is still undone, just to make sure that this series is okay to review so that I can continue to the Discord bot. There are 5 patches in this series: - Patch 1 is to move Telegram bot SC, bcz there will a Discord bot - Patch 2 is to refactor bot database to split between insert, del, get - Patch 3 is to rename some functions to make it understandable - Patch 4 is jsut remove some unecessary files - Patch 5 is to refactor many files like atoms, scraper, etc Patch 5 contains: - Rename some functions in utils - Rename file name in telegram such as scraper => mailer - Move class Mutexes to utility file - Rename the Mutexes attribute send_to_tg => lock - Changes affected codes during this refactor How to use: 1. Execute db.sql in daemon directory 2. Set value for environments for telegram bot, you can see the example in the telegram.env.example, this env file name must telegram.env 3. Set config.py in the telegram/config.py 4. Install all requirements package by executing `python3 -m pip install requirements.txt` in the telegram directory 5. Run the telegram bot by executing `python3 tg.py` in daemon directory Tested and works fine, thanks. Muhammad Rizki (5): [telegram] Move the Telegram bot source code [telegram] Refactor Telegram bot database method [telegram] Renaming some functions in scraper/bot.py [telegram] Remove unecessary files Refactor many files .gitignore | 4 +- daemon/atom/__init__.py | 7 + daemon/{scraper => atom}/scraper.py | 12 +- daemon/{scraper => atom}/utils.py | 87 +++++-- daemon/db.sql | 18 +- daemon/scraper/db.py | 217 ------------------ daemon/{.env.example => telegram.env.example} | 0 daemon/{ => telegram}/config.py.example | 0 daemon/telegram/database/__init__.py | 7 + daemon/telegram/database/core.py | 20 ++ daemon/telegram/database/methods/__init__.py | 17 ++ .../database/methods/deletion/__init__.py | 14 ++ .../database/methods/deletion/delet_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 | 62 +++++ .../methods/getter/get_telegram_reply.py | 33 +++ .../database/methods/insertion/__init__.py | 18 ++ .../database/methods/insertion/insert_atom.py | 27 +++ .../methods/insertion/insert_broadcast.py | 56 +++++ .../methods/insertion/insert_email.py | 27 +++ .../methods/insertion/insert_telegram.py | 21 ++ .../{scraper => telegram/mailer}/__init__.py | 4 +- .../bot.py => telegram/mailer/listener.py} | 48 ++-- daemon/{ => telegram}/packages/__init__.py | 0 daemon/{ => telegram}/packages/client.py | 12 +- daemon/{ => telegram}/packages/decorator.py | 0 .../packages/plugins/callbacks/del_atom.py | 6 +- .../packages/plugins/callbacks/del_chat.py | 6 +- .../packages/plugins/commands/debugger.py | 2 +- .../packages/plugins/commands/manage_atom.py | 8 +- .../plugins/commands/manage_broadcast.py | 8 +- .../packages/plugins/commands/scrape.py | 10 +- daemon/{ => telegram}/requirements.txt | 0 daemon/{ => telegram}/storage/.gitignore | 0 daemon/{run.py => tg.py} | 24 +- 38 files changed, 541 insertions(+), 324 deletions(-) create mode 100644 daemon/atom/__init__.py rename daemon/{scraper => atom}/scraper.py (79%) rename daemon/{scraper => atom}/utils.py (72%) delete mode 100644 daemon/scraper/db.py rename daemon/{.env.example => telegram.env.example} (100%) rename daemon/{ => telegram}/config.py.example (100%) create mode 100644 daemon/telegram/database/__init__.py create mode 100644 daemon/telegram/database/core.py create mode 100644 daemon/telegram/database/methods/__init__.py create mode 100644 daemon/telegram/database/methods/deletion/__init__.py create mode 100644 daemon/telegram/database/methods/deletion/delet_atom.py create mode 100644 daemon/telegram/database/methods/deletion/delete_broadcast.py create mode 100644 daemon/telegram/database/methods/getter/__init__.py create mode 100644 daemon/telegram/database/methods/getter/get_atom_urls.py create mode 100644 daemon/telegram/database/methods/getter/get_broadcast_chats.py create mode 100644 daemon/telegram/database/methods/getter/get_email_id.py create mode 100644 daemon/telegram/database/methods/getter/get_telegram_reply.py create mode 100644 daemon/telegram/database/methods/insertion/__init__.py create mode 100644 daemon/telegram/database/methods/insertion/insert_atom.py create mode 100644 daemon/telegram/database/methods/insertion/insert_broadcast.py create mode 100644 daemon/telegram/database/methods/insertion/insert_email.py create mode 100644 daemon/telegram/database/methods/insertion/insert_telegram.py rename daemon/{scraper => telegram/mailer}/__init__.py (68%) rename daemon/{scraper/bot.py => telegram/mailer/listener.py} (69%) rename daemon/{ => telegram}/packages/__init__.py (100%) rename daemon/{ => telegram}/packages/client.py (88%) rename daemon/{ => telegram}/packages/decorator.py (100%) rename daemon/{ => telegram}/packages/plugins/callbacks/del_atom.py (88%) rename daemon/{ => telegram}/packages/plugins/callbacks/del_chat.py (90%) rename daemon/{ => telegram}/packages/plugins/commands/debugger.py (97%) rename daemon/{ => telegram}/packages/plugins/commands/manage_atom.py (91%) rename daemon/{ => telegram}/packages/plugins/commands/manage_broadcast.py (92%) rename daemon/{ => telegram}/packages/plugins/commands/scrape.py (86%) rename daemon/{ => telegram}/requirements.txt (100%) rename daemon/{ => telegram}/storage/.gitignore (100%) rename daemon/{run.py => tg.py} (68%) base-commit: 2582d7e5225d47a01f606808fc71e5e6aa7cb153 -- Muhammad Rizki