public inbox for [email protected]
 help / color / mirror / Atom feed
* [RFC PATCH v5 00/18] Refactor Telegram & initial work Discord
@ 2022-09-25 21:14 Muhammad Rizki
  2022-09-25 21:14 ` [RFC PATCH v5 01/18] telegram: Move the Telegram bot source code Muhammad Rizki
                   ` (18 more replies)
  0 siblings, 19 replies; 26+ messages in thread
From: Muhammad Rizki @ 2022-09-25 21:14 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Muhammad Rizki, Alviro Iskandar Setiawan, GNU/Weeb Mailing List

Hi sir,
This series, Moving the Telegram bot source code to it's specific
directory because there will be a Discord bot so I must to split them.

Refactor the Telegram bot database method to split between insert,
get, and delete to make it more clean and maintainable.

Also, move the atom & utility source code to it's specific directory to
make it reusable functions to reduce code duplication.

Make initial work for Discord bot, it's still undone but it can run.
I just prepared for the event handlers such as on_error handler and
on_ready handler. on_error is to ignore error when any user in the
Discord channel typing a word that doesn't exist in the basic commands
bot like `ComandNotFound: "w"`. on_ready is to display a bot information
when it's successfuly run the bot, also prepared for the database
functions too, the methods pattern just like the Telegram bot,
also combine the tables in db.sql. Please send "$sync" on Discord
channel to sync the slash commands to the global.

There are 18 patches in this series:
- Patch 1 is to split the Telegram bot source code to it's specific dir
- Patch 2 is to refactor Telegram database method to split between funcs
- Patch 3 is to rename some functions to make it more readable
- Patch 4 is to add ignore file for any names that have .env extension
- Patch 5 is to move the Telegram bot runner script outside it's dir
- Patch 6 is to rename mailer directory and listener file
- Patch 7 is to move scraper and utility to it's specific directory
- Patch 8 is to commit initial work for Discord bot
- Patch 9 is to add a print success run in the on_ready event handler
- Patch 10 is to add an error handler in the on_error event handler
- Patch 11 is to move db.sql to the workdir and combine db tables
- Patch 12 is to add database tables for Discord bot in the db.sql file
- Patch 13 is to make an initial Discord bot database instance class
- Patch 14 is to add save_atom() function in database insertion dir
- Patch 15 is to add save_broadcast() function in database insertion dir
- Patch 16 is to add save_discord_mail() func in database insertion dir
- Patch 17 is to add save_email() func in database insertion dir
- Patch 18 is to add sync basic command to sync slash commands to global

How to use:
1. Execute 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. Setup the config.py in each bot directory such as dscord & 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`

This should be works fine, this version fix the whitespace errors and
fix the grammatical error. This version shouldhave better grammar T_T.

Muhammad Rizki (18):
  telegram: Move the Telegram bot source code
  telegram: Refactor the Telegram bot database method
  telegram: Rename some functions in scraper/bot.py
  Add ignore file for .env
  telegram: Refactor the Telegram bot
  telegram: Renames in telegram mailer directory
  Move scraper and utility file
  discord: Initial work for the Discord bot
  discord: Add success run notice on_ready event
  discord: Add error handler on events
  Move db.sql to combine the database with Discord and Telegram
  discord: Add database tables for the Discord bot
  discord: Add initial Discord bot database instance
  discord: Add save_atom() in database insertion
  discord: Add save_broadcast() in database insertion
  discord: Add save_discord_mail() in database insertion
  discord: Add save_email() in database insertion
  discord: Add $sync basic command

 .gitignore                                    |   4 +-
 daemon/{scraper => atom}/__init__.py          |   3 +-
 daemon/{scraper => atom}/scraper.py           |   0
 daemon/{scraper => atom}/utils.py             |   0
 daemon/db.sql                                 |  74 +++++-
 daemon/dc.py                                  |  20 ++
 daemon/discord.env.example                    |  11 +
 daemon/dscord/config.py.example               |  13 ++
 daemon/dscord/database/__init__.py            |   6 +
 daemon/dscord/database/core.py                |  17 ++
 daemon/dscord/database/methods/__init__.py    |  12 +
 .../database/methods/insertion/__init__.py    |  18 ++
 .../database/methods/insertion/insert_atom.py |  27 +++
 .../methods/insertion/insert_broadcast.py     |  42 ++++
 .../methods/insertion/insert_discord.py       |  14 ++
 .../methods/insertion/insert_email.py         |  20 ++
 daemon/dscord/gnuweeb/__init__.py             |   6 +
 daemon/dscord/gnuweeb/client.py               |  28 +++
 daemon/dscord/gnuweeb/plugins/__init__.py     |  20 ++
 .../plugins/basic_commands/__init__.py        |  11 +
 .../gnuweeb/plugins/basic_commands/sync_it.py |  20 ++
 .../dscord/gnuweeb/plugins/events/__init__.py |  13 ++
 .../dscord/gnuweeb/plugins/events/on_error.py |  17 ++
 .../dscord/gnuweeb/plugins/events/on_ready.py |  21 ++
 daemon/scraper/db.py                          | 217 ------------------
 daemon/{.env.example => telegram.env.example} |   3 +-
 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 ++
 daemon/telegram/mailer/__init__.py            |   8 +
 .../bot.py => telegram/mailer/listener.py}    |  31 +--
 daemon/{ => telegram}/packages/__init__.py    |   0
 daemon/{ => telegram}/packages/client.py      |   6 +-
 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       |   8 +-
 daemon/{ => telegram}/requirements.txt        |   0
 daemon/{ => telegram}/storage/.gitignore      |   0
 daemon/{run.py => tg.py}                      |  14 +-
 57 files changed, 852 insertions(+), 274 deletions(-)
 rename daemon/{scraper => atom}/__init__.py (80%)
 rename daemon/{scraper => atom}/scraper.py (100%)
 rename daemon/{scraper => atom}/utils.py (100%)
 create mode 100644 daemon/dc.py
 create mode 100644 daemon/discord.env.example
 create mode 100644 daemon/dscord/config.py.example
 create mode 100644 daemon/dscord/database/__init__.py
 create mode 100644 daemon/dscord/database/core.py
 create mode 100644 daemon/dscord/database/methods/__init__.py
 create mode 100644 daemon/dscord/database/methods/insertion/__init__.py
 create mode 100644 daemon/dscord/database/methods/insertion/insert_atom.py
 create mode 100644 daemon/dscord/database/methods/insertion/insert_broadcast.py
 create mode 100644 daemon/dscord/database/methods/insertion/insert_discord.py
 create mode 100644 daemon/dscord/database/methods/insertion/insert_email.py
 create mode 100644 daemon/dscord/gnuweeb/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/client.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/basic_commands/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/basic_commands/sync_it.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/events/__init__.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/events/on_error.py
 create mode 100644 daemon/dscord/gnuweeb/plugins/events/on_ready.py
 delete mode 100644 daemon/scraper/db.py
 rename daemon/{.env.example => telegram.env.example} (82%)
 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
 create mode 100644 daemon/telegram/mailer/__init__.py
 rename daemon/{scraper/bot.py => telegram/mailer/listener.py} (77%)
 rename daemon/{ => telegram}/packages/__init__.py (100%)
 rename daemon/{ => telegram}/packages/client.py (95%)
 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 (91%)
 rename daemon/{ => telegram}/requirements.txt (100%)
 rename daemon/{ => telegram}/storage/.gitignore (100%)
 rename daemon/{run.py => tg.py} (78%)


base-commit: 2582d7e5225d47a01f606808fc71e5e6aa7cb153
--
Muhammad Rizki

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2022-09-30 13:39 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-25 21:14 [RFC PATCH v5 00/18] Refactor Telegram & initial work Discord Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 01/18] telegram: Move the Telegram bot source code Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 02/18] telegram: Refactor the Telegram bot database method Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 03/18] telegram: Rename some functions in scraper/bot.py Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 04/18] Add ignore file for .env Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 05/18] telegram: Refactor the Telegram bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 06/18] telegram: Renames in telegram mailer directory Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 07/18] Move scraper and utility file Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 08/18] discord: Initial work for the Discord bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 09/18] discord: Add success run notice on_ready event Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 10/18] discord: Add error handler on events Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 11/18] Move db.sql to combine the database with Discord and Telegram Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 12/18] discord: Add database tables for the Discord bot Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 13/18] discord: Add initial Discord bot database instance Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 14/18] discord: Add save_atom() in database insertion Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 15/18] discord: Add save_broadcast() " Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 16/18] discord: Add save_discord_mail() " Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 17/18] discord: Add save_email() " Muhammad Rizki
2022-09-25 21:14 ` [RFC PATCH v5 18/18] discord: Add $sync basic command Muhammad Rizki
2022-09-25 21:31 ` [RFC PATCH v5 00/18] Refactor Telegram & initial work Discord Ammar Faizi
2022-09-25 21:37   ` Muhammad Rizki
2022-09-25 21:48     ` Ammar Faizi
2022-09-25 21:52       ` Muhammad Rizki
2022-09-25 21:58         ` Ammar Faizi
2022-09-30 12:21           ` Ammar Faizi
2022-09-30 13:39             ` Muhammad Rizki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox