Skip to content

Commit

Permalink
Release Version 2.0.0
Browse files Browse the repository at this point in the history
# v2.0.0

Added dotenv to have environment variables (channed id, bot token) seperate from the main script in the form of a .env file.
    This is more for my sake cause i'm an idiot and will end up leaking sensitive info.
Added the `.env` file to gitignore, will add `.env` file manually after for documentation and instruction purpose.
Changed service message formatting slightly under `run.py`.
Added `.github\workflows\python-version-check.yml` to do testing for various Python versions, this to run on pushes and pull requests.
  • Loading branch information
redtrillix committed Mar 31, 2024
1 parent ee99f56 commit c31a23f
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TOKEN=your_bot_token_here
CHANNEL_ID=your_channel_id_here
42 changes: 42 additions & 0 deletions .github/workflows/python-version-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Python package

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
- name: Run Python script
run: python run.py
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Changelog

# v2.0.0
Added dotenv to have environment variables (channed id, bot token) seperate from the main script in the form of a .env file.
This is more for my sake cause i'm an idiot and will end up leaking sensitive info.
Added the `.env` file to gitignore, will add `.env` file manually after for documentation and instruction purpose.
Changed service message formatting slightly under `run.py`.
Added `.github\workflows\python-version-check.yml` to do testing for various Python versions, this to run on pushes and pull requests.

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

Expand Down
15 changes: 10 additions & 5 deletions run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Version: 1.1.0
## Version: 2.0.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
Expand All @@ -11,12 +11,16 @@
import socket
import psutil
import requests
from dotenv import load_dotenv

# Load environment variables from .env file
load_dotenv()

# Discord bot token
TOKEN = 'your_bot_token_here'
TOKEN = os.getenv('TOKEN')

# Channel ID where you want to send the message
CHANNEL_ID = 'your_channel_id_here'
CHANNEL_ID = os.getenv('CHANNEL_ID')

# Define the services that are up and running
services = ["Service1", "Service2", "Service3", "Service4", "Service5"]
Expand Down Expand Up @@ -44,8 +48,9 @@
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"
MESSAGE += "\n".join([f"- {service}" for service in services])
MESSAGE += "**Services Running:**\n"
for index, service in enumerate(services, start=1):
MESSAGE += f"{index}. {service}\n"

# Define the intents
intents = Intents.default()
Expand Down

0 comments on commit c31a23f

Please sign in to comment.