GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
* [PATCH v1 00/16] Fix, improvement and implement a bot logger.
@ 2022-11-04 18:09 Muhammad Rizki
  2022-11-04 18:09 ` [PATCH v1 01/16] discord: Fix typo on _flood_exception() Muhammad Rizki
                   ` (23 more replies)
  0 siblings, 24 replies; 45+ messages in thread
From: Muhammad Rizki @ 2022-11-04 18:09 UTC (permalink / raw)
  To: Ammar Faizi
  Cc: Muhammad Rizki, Alviro Iskandar Setiawan, GNU/Weeb Mailing List

Hi sir,

This series contains fixes in the utility file and some improvement for
it. I also implement a bot logger to log an error to the terminal and
to the log file, if error may happen it will send the log file to the
log channel either for Discord or Telegram, the LOG_CHANNEL_ID is
declared in the config.py.example, copy the channel ID from the Discord
or Telegram channel and then paste to the config.py.example.

There are 16 patches in this series:
- Patch 1 is to fix a typo
- Patch 2 is to fix an extract_list() when there is no receipients
- Patch 3 is to change max receipients list header like CC/TO
- Patch 4 is to use the old one method, use decode=True in get_payload()
- Patch 5 is to improve fix_utf8_char(), make sure to unescape the HTML
- Patch 6 is to add a utility catch_err() function to get error message
- Patch 7 is to just add an initial BotLogger() to use it in next commit
- Patch 8 is to use the created BotLogger() for the Telegram bot
- Patch 9 is to add a Telegram LOG_CHANNEL_ID for the send_log_file()
- Patch 10 is to add a send_log_file() for the Telegram bot DaemonClient
- Patch 11 is to implement the log message and send log file for TG bot
- Patch 12 is to add a Discord LOG_CHANNEL_ID for the send_log_file()
- Patch 13 is to use the created BotLogger() for the Discord bot
- Patch 14 is to add a send_log_file() for the Discord bot GWClient()
- Patch 15 is to implement the log message and send log file for DC bot
- Patch 16 is to remove unused imports

What's new?
- Implementation of the BotLogger to log error message.
- Add a catch_err() in the atom/utils.py.
- Add a send_log_file() in each bot client.py.
- Add a variable LOG_CHANNEL_ID to configure the log channel.

What's changed?
- Some utility functions are fixed and improved.
- Fix typo on _flood_exception()

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

Tested and works, please give it a test, thanks!

Muhammad Rizki (16):
  discord: Fix typo on _flood_exception()
  fix: utils: Fix the extract_list() utility function
  utils: Change on max for TO/CC header list
  utils: Back to use decode=True for the get_payload()
  utils: Improve fix_utf8_char()
  utils: Add catch_err() for the log message
  logger: Initial work for the bot logger for future use
  telegram: Use the created BotLogger() class
  telegram: Add variable LOG_CHANNEL_ID declaration
  telegram: Add send_log_file() in the DaemonClient()
  telegram: Implement the log message for catching errors
  discord: Add variable LOG_CHANNEL_ID declaration
  discord: Use the BotLogger() to the GWClient()
  discord: Add send_log_file in the GWClient()
  discord: Implement the catch erros and logs
  Remove some unused imports

 daemon/atom/utils.py                          | 50 ++++++++++++------
 daemon/dc.py                                  | 10 +++-
 daemon/dscord/config.py.example               |  4 ++
 daemon/dscord/gnuweeb/client.py               | 20 +++++--
 daemon/dscord/gnuweeb/filters.py              | 10 ++--
 .../dscord/gnuweeb/plugins/events/on_ready.py |  2 +-
 .../plugins/slash_commands/get_lore_mail.py   | 12 +++--
 daemon/dscord/mailer/listener.py              | 41 ++++++++-------
 daemon/logger/__init__.py                     |  1 +
 daemon/logger/log.py                          | 52 +++++++++++++++++++
 daemon/telegram/config.py.example             |  4 ++
 daemon/telegram/mailer/listener.py            | 44 ++++++++++------
 daemon/telegram/packages/client.py            | 21 ++++++--
 daemon/telegram/packages/decorator.py         | 15 +++---
 .../packages/plugins/commands/scrape.py       | 10 +++-
 daemon/tg.py                                  |  5 ++
 16 files changed, 223 insertions(+), 78 deletions(-)
 create mode 100644 daemon/logger/__init__.py
 create mode 100644 daemon/logger/log.py


base-commit: 91e86e6d1004da4526ca5514fa009bc253d5c4a3
--
Muhammad Rizki

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

end of thread, other threads:[~2022-11-07  1:50 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-04 18:09 [PATCH v1 00/16] Fix, improvement and implement a bot logger Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 01/16] discord: Fix typo on _flood_exception() Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 02/16] fix: utils: Fix the extract_list() utility function Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 03/16] utils: Change on max for TO/CC header list Muhammad Rizki
2022-11-07  0:55   ` Ammar Faizi
2022-11-07  1:08     ` Muhammad Rizki
2022-11-07  1:15       ` Ammar Faizi
2022-11-07  1:24         ` Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 04/16] utils: Back to use decode=True for the get_payload() Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 05/16] utils: Improve fix_utf8_char() Muhammad Rizki
2022-11-07  1:01   ` Ammar Faizi
2022-11-07  1:11     ` Muhammad Rizki
2022-11-07  1:26       ` Ammar Faizi
2022-11-07  1:27         ` Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 06/16] utils: Add catch_err() for the log message Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 07/16] logger: Initial work for the bot logger for future use Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 08/16] telegram: Use the created BotLogger() class Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 09/15] telegram: Add send_log_file() in the DaemonClient() Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 09/16] telegram: Add variable LOG_CHANNEL_ID declaration Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 10/16] telegram: Add send_log_file() in the DaemonClient() Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 10/15] telegram: Implement the log message for catching errors Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 11/15] discord: Add variable LOG_CHANNEL_ID declaration Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 11/16] telegram: Implement the log message for catching errors Muhammad Rizki
2022-11-07  1:05   ` Ammar Faizi
2022-11-07  1:13     ` Muhammad Rizki
2022-11-07  1:16       ` Ammar Faizi
2022-11-07  1:26         ` Muhammad Rizki
2022-11-07  1:31           ` Ammar Faizi
2022-11-07  1:34             ` Muhammad Rizki
2022-11-07  1:42               ` Ammar Faizi
2022-11-07  1:48                 ` Muhammad Rizki
2022-11-07  1:50                 ` Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 12/16] discord: Add variable LOG_CHANNEL_ID declaration Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 12/15] discord: Use the BotLogger() to the GWClient() Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 13/15] discord: Add send_log_file in " Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 13/16] discord: Use the BotLogger() to " Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 14/16] discord: Add send_log_file in " Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 14/15] discord: Implement the catch erros and logs Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 15/15] Remove some unused imports Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 15/16] discord: Implement the catch erros and logs Muhammad Rizki
2022-11-04 18:09 ` [PATCH v1 16/16] Remove some unused imports Muhammad Rizki
2022-11-07  1:10 ` [PATCH v1 00/16] Fix, improvement and implement a bot logger Ammar Faizi
2022-11-07  1:16   ` Muhammad Rizki
2022-11-07  1:28   ` Muhammad Rizki
2022-11-07  1:31     ` Ammar Faizi

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