DiscordBotLinuxMonitor 1.1.1__tar.gz → 1.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiscordBotLinuxMonitor
3
- Version: 1.1.1
3
+ Version: 1.2.2
4
4
  Summary: From discord channels: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
5
5
  Home-page: https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
@@ -22,7 +22,7 @@ Classifier: Environment :: Console
22
22
  Requires-Python: >=3.3
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.md
25
- Requires-Dist: linuxmonitor
25
+ Requires-Dist: linuxmonitor~=1.2.0
26
26
  Requires-Dist: discord.py
27
27
  Requires-Dist: typing
28
28
  Requires-Dist: asyncio
@@ -60,6 +60,9 @@ Displayed infos are not the same if you do the command in private or public chan
60
60
  - `/ping`: 🌐 Ping websites 🌐
61
61
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
62
62
 
63
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
64
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
65
+
63
66
  - `/certificates`: 🔒 Check SSL certificates 🔒
64
67
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
65
68
 
@@ -1,4 +1,4 @@
1
- linuxmonitor
1
+ linuxmonitor~=1.2.0
2
2
  discord.py
3
3
  typing
4
4
  asyncio
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: DiscordBotLinuxMonitor
3
- Version: 1.1.1
3
+ Version: 1.2.2
4
4
  Summary: From discord channels: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)
5
5
  Home-page: https://github.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library
6
6
  Author: Quentin Comte-Gaz
@@ -22,7 +22,7 @@ Classifier: Environment :: Console
22
22
  Requires-Python: >=3.3
23
23
  Description-Content-Type: text/markdown
24
24
  License-File: LICENSE.md
25
- Requires-Dist: linuxmonitor
25
+ Requires-Dist: linuxmonitor~=1.2.0
26
26
  Requires-Dist: discord.py
27
27
  Requires-Dist: typing
28
28
  Requires-Dist: asyncio
@@ -60,6 +60,9 @@ Displayed infos are not the same if you do the command in private or public chan
60
60
  - `/ping`: 🌐 Ping websites 🌐
61
61
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
62
62
 
63
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
64
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
65
+
63
66
  - `/certificates`: 🔒 Check SSL certificates 🔒
64
67
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
65
68
 
@@ -31,6 +31,9 @@ Displayed infos are not the same if you do the command in private or public chan
31
31
  - `/ping`: 🌐 Ping websites 🌐
32
32
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/ping.jpg" height="150">
33
33
 
34
+ - `/websites`: 🌐 Check websites access (GET requests) 🌐
35
+ <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/websites.jpg" height="150">
36
+
34
37
  - `/certificates`: 🔒 Check SSL certificates 🔒
35
38
  <img src="https://raw.githubusercontent.com/QuentinCG/Discord-Bot-Linux-Monitor-Python-Library/master/example/certificates.jpg" height="400">
36
39
 
@@ -74,6 +74,10 @@ def main() -> None:
74
74
  async def ping(interaction: discord.Interaction) -> None: # type: ignore
75
75
  await discord_bot_linux_monitor.ping(interaction)
76
76
 
77
+ @discord_bot.tree.command(name="websites", description="🌐 Check websites access (GET requests) 🌐")
78
+ async def websites(interaction: discord.Interaction) -> None: # type: ignore
79
+ await discord_bot_linux_monitor.websites(interaction)
80
+
77
81
  @discord_bot.tree.command(name="certificates", description="🔒 Check SSL certificates 🔒")
78
82
  async def certificates(interaction: discord.Interaction) -> None: # type: ignore
79
83
  await discord_bot_linux_monitor.certificates(interaction)
@@ -11,6 +11,7 @@ Non exhaustive list of features (available by using it in shell or in python scr
11
11
  - Check disk usage
12
12
  - Check folder usage
13
13
  - Check websites basic availability (ping)
14
+ - Check websites access with optional authentication (GET request)
14
15
  - Check services status and restart them if needed
15
16
  - Check certificates expiration and validity
16
17
  - Check last user connections IPs
@@ -30,7 +31,7 @@ __email__ = "quentin@comte-gaz.com"
30
31
  __license__ = "MIT License"
31
32
  __copyright__ = "Copyright Quentin Comte-Gaz (2024)"
32
33
  __python_version__ = "3.+"
33
- __version__ = "1.1.1 (2024/09/14)"
34
+ __version__ = "1.2.2 (2024/09/19)"
34
35
  __status__ = "Usable for any Linux project"
35
36
 
36
37
  # pyright: reportMissingTypeStubs=false
@@ -546,6 +547,26 @@ class DiscordBotLinuxMonitor:
546
547
  logging.exception(msg=out_msg)
547
548
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
548
549
 
550
+ async def websites(self, interaction: discord.Interaction) -> None:
551
+ if not self._check_if_valid_guild(guild=interaction.guild):
552
+ return
553
+ if not (await self._is_bot_channel_interaction(interaction=interaction, send_message_if_not_bot=True)):
554
+ return
555
+
556
+ # Say to the user that the command is being processed
557
+ await interaction.response.defer()
558
+
559
+ try:
560
+ is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
561
+ out_msg: str = await self.monitoring.check_all_websites(is_private=is_private, display_only_if_critical=False, restart_if_down=True)
562
+
563
+ # Respond to the user
564
+ await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
565
+ except Exception as e:
566
+ out_msg = f"**Internal error during websites access check **:\n```sh\n{e}\n```"
567
+ logging.exception(msg=out_msg)
568
+ await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
569
+
549
570
  async def certificates(self, interaction: discord.Interaction) -> None:
550
571
  if not self._check_if_valid_guild(guild=interaction.guild):
551
572
  return
@@ -683,7 +704,7 @@ class DiscordBotLinuxMonitor:
683
704
  try:
684
705
  # Récupérer le statut des ports
685
706
  is_private: bool = self._is_private_channel(channel=interaction.channel) # type: ignore
686
- out_msg: str = await self.monitoring.check_all_ports(restart_if_down=True, is_private=is_private, display_only_if_critical=False)
707
+ out_msg: str = await self.monitoring.check_all_ports(is_private=is_private, display_only_if_critical=False, restart_if_down=True)
687
708
 
688
709
  # Répondre à l'utilisateur
689
710
  await self._interaction_followup_send_no_limit(interaction=interaction, msg=out_msg)
@@ -6,7 +6,7 @@ with io.open(file='README.md', mode='r', encoding='utf-8') as readme_file:
6
6
 
7
7
  setup(
8
8
  name="DiscordBotLinuxMonitor",
9
- version="1.1.1",
9
+ version="1.2.2",
10
10
  description="From discord channels: Get information and warning status of Linux server like service, port, ping, ssl certificate, disk/folder/cpu/ram/swap usage, ip connection, ... (Python and shell library, Linux ONLY)",
11
11
  long_description=readme,
12
12
  long_description_content_type="text/markdown",
@@ -36,7 +36,7 @@ setup(
36
36
  keywords='discord bot warning info linux monitor monitoring server service port ping ssl certificate disk folder cpu ram swap usage ip connection',
37
37
  platforms='Linux',
38
38
  install_requires=[
39
- "linuxmonitor",
39
+ "linuxmonitor~=1.2.0", # follows the {MAJOR}.{MINOR}.x version range (because LinuxMonitor and DiscordBotLinuxMonitor are tightly coupled and should have same major and minor version)
40
40
  "discord.py",
41
41
  "typing",
42
42
  "asyncio",