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: [PATCH v1 00/13] Improvements, refactors, and features
Date: Tue,  3 Jan 2023 13:36:28 +0700	[thread overview]
Message-ID: <[email protected]> (raw)

Hir sir,
This is v1 of Improvements, refactors, and features. This series is to
move a function, code Improvements, add a function, and add an error
class.

In the last series, I didn't care so much with the Discord
implementation. So, I forget to add a reconnect MySQL method for the
Discord bot. In this series, I've added it and implement it in the
listener.py exactly in the handle_db_error().

In the last commit, Telegram report_err() is implemented in the
listener.py. In this series, I've been move it to the Telegram bot
custom client instead. I've added a report_err() for the Discord bot
too in the client.

I've added DaemonException() error class too to easily save a thread URL
if errors may happen, this error class is to easily reproducing errors.

Some unnecessary try/except block is already removed and add the
try/except block again in the __handle_atom_url(), we need to catch the
thread URL to easily reproducing errors if errors may happen in the
future.

I've implemented handle_db_error() for the Discord bot too.

What's new?
- Added a report_err() for the Discord bot.
- Added a DaemonException() error class for both bots.
- Added a ping() for reconnecting MySQL conn for the Discord bot.
- Added a handle_db_error() for the Discord bot mail listener.

Refactors:
- Move report_err() to the DaemonTelegram() for the Telegram bot.
- Remove try/except for both bots in their listener.py.
- Ensure the Telegram bot has been started, so start the client earlier.
- Rename the Telegram bot custom client to "DaemonTelegram".

There are 13 patches in this series:
- Patch 1 is to remove unnecessary try/except in the listener for DC bot.
- Patch 2 is to move report_err() from listener to DaemonTelegram().
- Patch 3 is to ensure the Telegram bot has been started before interact.
- Patch 4 is to added DaemonException() error class to handle error.
- Patch 5 is to implement the DaemonException() error class for the TG.
- Patch 6 is to remove unnecessary try/except in the listener for TG bot
- Patch 7 is to added report_err() for the Discord bot in the client.
- Patch 8 is to implement the report_err() in the Discord mail listener.
- Patch 9 is to added ping() method to reconnect MySQL connection for DC.
- Patch 10 is to added handle_db_error() in the listener for the DC bot.
- Patch 11 is to handle MySQL connection error in the listener for the DC
- Patch 12 is to implement the DaemonException() error class for the DC.
- Patch 13 is to rename the Telegram bot custom client to DaemonTelegram()

How to set log channel ID for the Telegram bot:
1. Make a channel for log in the Telegram.
2. Copy the channel ID, if you unable to see the ID you can use API or
   bot who has the feature, or use a 64gram desktop.
3. Paste the copied ID into the config.py in the telegram directory.

How to set log channel ID for the Discord bot:
1. Make a channel for log in your Discord server.
2. Copy the channel ID by right click and copy, if you unable to get the
   ID you can go to your account settings, then enable the
   `Developer mode` or use bot who has the feature.
3. Paste the copied ID into the config.py in the dscord directory.

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`.

Please give it a test and give me more comments or suggestion, thanks!

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

Muhammad Rizki (13):
  refactor(discord): Remove unnecessary try/except block
  refactor(telegram): Move report_err() to the DaemonClient() class
  refactor(telegram)!: Ensure the Telegram bot has been started
  feat: add DaemonException() class
  feat(telegram): Implement the DaemonException() class
  refactor(telegram/mailer)!: Remove unnecessary try/except block
  feat(discord): add report_err() for the Discord bot
  feat(discord): Implement the report_err()
  feat(discord/database): Add ping() method
  feat(discord): Add handle_db_error in the listener.py
  feat(discord): Handle MySQL connection error in the mail listener
  feat(discord): Implement the DaemonException for handle error
  refactor(telegram)!: Rename the Telegram bot custom client

 daemon/dscord/database/core.py                |  6 +++
 daemon/dscord/gnuweeb/client.py               |  8 ++++
 daemon/dscord/mailer/listener.py              | 48 ++++++++++++++-----
 daemon/exceptions.py                          | 18 +++++++
 daemon/telegram/mailer/listener.py            | 36 +++++++-------
 daemon/telegram/packages/__init__.py          |  2 +-
 daemon/telegram/packages/client.py            | 10 +++-
 daemon/telegram/packages/decorator.py         |  2 +-
 .../packages/plugins/callbacks/del_atom.py    |  6 +--
 .../packages/plugins/callbacks/del_chat.py    |  6 +--
 .../packages/plugins/commands/manage_atom.py  | 10 ++--
 .../plugins/commands/manage_broadcast.py      | 10 ++--
 .../packages/plugins/commands/scrape.py       |  6 +--
 daemon/tg.py                                  | 11 +++--
 14 files changed, 120 insertions(+), 59 deletions(-)
 create mode 100644 daemon/exceptions.py


base-commit: d72337c346686b7faa48ee654c967dba1dfebea0
--
Muhammad Rizki

             reply	other threads:[~2023-01-03  6:36 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03  6:36 Muhammad Rizki [this message]
2023-01-03  6:36 ` [PATCH v1 01/13] refactor(discord): Remove unnecessary try/except block Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 02/13] refactor(telegram): Move report_err() to the DaemonClient() class Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 03/13] refactor(telegram)!: Ensure the Telegram bot has been started Muhammad Rizki
2023-01-03  6:54   ` Ammar Faizi
2023-01-03 12:17     ` Muhammad Rizki
2023-01-03 22:11       ` Ammar Faizi
2023-01-03 22:27         ` Alviro Iskandar Setiawan
2023-01-03 22:28           ` Ammar Faizi
2023-01-04  6:31           ` Muhammad Rizki
2023-01-04  6:39             ` Alviro Iskandar Setiawan
2023-01-04  6:50               ` Muhammad Rizki
2023-01-04  6:50               ` Ammar Faizi
2023-01-04  7:02                 ` Alviro Iskandar Setiawan
2023-01-04  7:05                   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 04/13] feat: add DaemonException() class Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 05/13] feat(telegram): Implement the " Muhammad Rizki
2023-01-03  7:09   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 06/13] refactor(telegram/mailer)!: Remove unnecessary try/except block Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 07/13] feat(discord): add report_err() for the Discord bot Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 08/13] feat(discord): Implement the report_err() Muhammad Rizki
2023-01-03  7:14   ` Ammar Faizi
2023-01-03  7:17     ` Ammar Faizi
2023-01-03 12:20     ` Muhammad Rizki
2023-01-03 22:20       ` Ammar Faizi
2023-01-04  8:21         ` Muhammad Rizki
2023-01-04  8:30           ` Ammar Faizi
2023-01-04  8:37             ` Ammar Faizi
2023-01-04  8:51               ` Ammar Faizi
2023-01-07  6:10         ` Muhammad Rizki
2023-01-07  6:18           ` Ammar Faizi
2023-01-07  6:22             ` Alviro Iskandar Setiawan
2023-01-07  6:26               ` Ammar Faizi
2023-01-07  7:02               ` Muhammad Rizki
2023-01-07  7:03                 ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 09/13] feat(discord/database): Add ping() method Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 10/13] feat(discord): Add handle_db_error in the listener.py Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 11/13] feat(discord): Handle MySQL connection error in the mail listener Muhammad Rizki
2023-01-03  7:19   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 12/13] feat(discord): Implement the DaemonException for handle error Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 13/13] refactor(telegram)!: Rename the Telegram bot custom client Muhammad Rizki
2023-01-03  7:25 ` [PATCH v1 00/13] Improvements, refactors, and features 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