From ee99f56a66c34306302e9b9c9436063b26abb0e9 Mon Sep 17 00:00:00 2001 From: Zachary G Date: Sun, 31 Mar 2024 17:07:03 +0800 Subject: [PATCH] Release v1.1.0 # v1.1.0 Change IP logging from Local computer interface IP to using the service 'https://httpbin.org' to get the Public IP of the computer. --- changelog.txt | 3 +++ run.py | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/changelog.txt b/changelog.txt index 5f84939..3c3a6a1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ ## Changelog +# v1.1.0 +Change IP logging from Local computer interface IP to using the service 'https://httpbin.org' to get the Public IP of the computer. + # v1.0.0 - Initial Full Release Added psutil dependency for CPU and Memory logging in Discord message. Added socket dependency for Hostname and IP logging in Discord message. diff --git a/run.py b/run.py index 7c9dfec..0223739 100644 --- a/run.py +++ b/run.py @@ -1,4 +1,4 @@ -## Version: 1.0.0 +## Version: 1.1.0 ## License: https://github.com/redtrillix/DiscordComputerStatus/raw/main/LICENSE ## Git Repository: https://github.com/redtrillix/DiscordComputerStatus ## Changelog: https://github.com/redtrillix/DiscordComputerStatus/blob/main/CHANGELOG.txt @@ -10,6 +10,7 @@ from datetime import datetime import socket import psutil +import requests # Discord bot token TOKEN = 'your_bot_token_here' @@ -26,8 +27,11 @@ # Get the hostname hostname = socket.gethostname() -# Get the IP address -ip_address = socket.gethostbyname(hostname) +# Get the public IP address +try: + public_ip = requests.get('https://httpbin.org/ip').json()['origin'] +except Exception as e: + public_ip = "Unavailable" # Get CPU and memory usage cpu_usage = psutil.cpu_percent() @@ -37,7 +41,7 @@ MESSAGE = f"**System Notification:**\n\n" MESSAGE += f"🔔 System turned on at {current_time}.\n" MESSAGE += f"🖥️ Hostname: {hostname}\n" -MESSAGE += f"🌐 IP Address: {ip_address}\n" +MESSAGE += f"🌐 Public IP Address: {public_ip}\n" MESSAGE += f"💻 CPU Usage: {cpu_usage}%\n" MESSAGE += f"🧠 Memory Usage: {memory_usage}%\n\n" MESSAGE += "**Services Running:**\n\n"