public inbox for [email protected]
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [RFC PATCH v4 00/17] Refactor Telegram & initial work Discord
Date: Tue, 20 Sep 2022 20:47:55 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

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.

There are 17 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

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`

Conclusion:
Only change in commit title and description, no other code change. This
should be works fine.

Request:
Please test it first so I can do more revision in a review, with this,
I can continue this progress faster, but, if you want this project there
is no need to rush that's okay, as long as you increase the time for
making this project, thanks.

## Changelog

v3 -> v4
- Change commits title & description grammar

v2 -> v3
- Change commit description for commit 07/17

v1 -> v2
- Remove the ignore file in .gitignore while the file is not added yet.
- Change prefix name each commits from `[]` to `:`
- Change commit description for commit 05/17

Signed-off-by: Muhammad Rizki <[email protected]>
---

Muhammad Rizki (17):
  telegram: Move the Telegram bot source code
  telegram: Refactor 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 Discord bot
  discord: Add success run notice on_ready event
  discord: Add error handler on events
  Move db.sql to combine database with Discord and Telegram
  discord: Add database tables for 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

 .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     |  17 ++
 .../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 +-
 55 files changed, 818 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/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


             reply	other threads:[~2022-09-20 13:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 13:47 Muhammad Rizki [this message]
2022-09-20 13:47 ` [RFC PATCH v4 01/17] telegram: Move the Telegram bot source code Muhammad Rizki
2022-09-23 17:26   ` Alviro Iskandar Setiawan
2022-09-20 13:47 ` [RFC PATCH v4 02/17] telegram: Refactor Telegram bot database method Muhammad Rizki
2022-09-23 17:12   ` Ammar Faizi
2022-09-20 13:47 ` [RFC PATCH v4 03/17] telegram: Rename some functions in scraper/bot.py Muhammad Rizki
2022-09-20 13:47 ` [RFC PATCH v4 04/17] Add ignore file for .env Muhammad Rizki
2022-09-23 17:51   ` Alviro Iskandar Setiawan
2022-09-20 13:48 ` [RFC PATCH v4 05/17] telegram: Refactor the Telegram bot Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 06/17] telegram: Renames in telegram mailer directory Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 07/17] Move scraper and utility file Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 08/17] discord: Initial work Discord bot Muhammad Rizki
2022-09-23 17:13   ` Ammar Faizi
2022-09-23 17:21     ` Muhammad Rizki
2022-09-23 17:37       ` Alviro Iskandar Setiawan
2022-09-23 17:40         ` Alviro Iskandar Setiawan
2022-09-23 17:42           ` Ammar Faizi
2022-09-23 17:52           ` Muhammad Rizki
2022-09-23 17:55             ` Alviro Iskandar Setiawan
2022-09-23 18:00               ` Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 09/17] discord: Add success run notice on_ready event Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 10/17] discord: Add error handler on events Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 11/17] Move db.sql to combine database with Discord and Telegram Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 12/17] discord: Add database tables for Discord bot Muhammad Rizki
2022-09-23 17:50   ` Alviro Iskandar Setiawan
2022-09-20 13:48 ` [RFC PATCH v4 13/17] discord: Add initial Discord bot database instance Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 14/17] discord: Add save_atom() in database insertion Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 15/17] discord: Add save_broadcast() " Muhammad Rizki
2022-09-20 13:48 ` [RFC PATCH v4 16/17] discord: Add save_discord_mail() " Muhammad Rizki
2022-09-23 17:14   ` Ammar Faizi
2022-09-20 13:48 ` [RFC PATCH v4 17/17] discord: Add save_email() " Muhammad Rizki
2022-09-20 15:57 ` [RFC PATCH v4 00/17] Refactor Telegram & initial work Discord Ammar Faizi
2022-09-23 16:42 ` Ammar Faizi
2022-09-23 16:57   ` Muhammad Rizki
2022-09-23 17:00     ` Ammar Faizi
2022-09-23 17:02       ` Muhammad Rizki
2022-09-23 17:04         ` Ammar Faizi
2022-09-23 17:06           ` Ammar Faizi
2022-09-23 17:17             ` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox