Skip to content

Commit

Permalink
Enhanced logging and updated version
Browse files Browse the repository at this point in the history
- Added file logging with directory and log file creation
- Simplified import statements
- Improved logging format and handlers
- Updated version to v1.0.5
  • Loading branch information
Jesewe authored Aug 6, 2024
1 parent e737c47 commit 5fc95b8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ By default, the TriggerBot uses the 'X' key to trigger. You can change the trigg
- Automatically detects enemies and triggers mouse clicks.
- Fetches the latest offsets from an online source.
- Checks for script updates and notifies the user if a new version is available.
- Logs all actions and errors.
- Logs all actions and errors to a specified log file and displays logs on the console.

## Logging
The TriggerBot logs all actions and errors in a log file located at `%LOCALAPPDATA%\Requests\ItsJesewe\crashes\logs.log`. The log file and directory are created automatically if they do not exist.

## Contributing
Contributions are welcome! Please submit a pull request or open an issue to discuss your ideas.
Expand Down
26 changes: 20 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
import pymem
import pymem.process
import keyboard
import time
import time, keyboard, os, ctypes
from pynput.mouse import Controller, Button
from win32gui import GetWindowText, GetForegroundWindow
from random import uniform
import logging
from requests import get
from packaging import version
from colorama import init, Fore, Style
import ctypes

init(autoreset=True)

mouse = Controller()
VERSION = "v1.0.4"
VERSION = "v1.0.5"
TRIGGER_KEY = 'X'

LOG_DIRECTORY = os.path.expandvars(r'%LOCALAPPDATA%\Requests\ItsJesewe\crashes')
LOG_FILE = os.path.join(LOG_DIRECTORY, 'logs.log')

if not os.path.exists(LOG_DIRECTORY):
os.makedirs(LOG_DIRECTORY)

with open(LOG_FILE, 'w') as f:
pass

file_handler = logging.FileHandler(LOG_FILE)
file_handler.setFormatter(logging.Formatter(f'%(levelname)s: %(message)s'))

console_handler = logging.StreamHandler()
console_handler.setFormatter(logging.Formatter(f'%(levelname)s: {Fore.CYAN}%(message)s{Style.RESET_ALL}'))

logging.basicConfig(level=logging.INFO, handlers=[file_handler, console_handler])

def set_console_title(title):
ctypes.windll.kernel32.SetConsoleTitleW(title)

Expand Down Expand Up @@ -74,7 +89,6 @@ def should_trigger(entity_team, player_team, entity_health):

def main():
set_console_title(f"CS2 TriggerBot {VERSION}")
logging.basicConfig(level=logging.INFO, format=f'%(levelname)s - {Fore.CYAN}%(message)s{Style.RESET_ALL}')
check_for_updates()
logging.info(f"{Fore.CYAN}Fetching offsets and client data...")

Expand All @@ -101,7 +115,7 @@ def main():
input(f"{Fore.RED}Press Enter to exit...")
return

logging.info(f"{Fore.CYAN}TriggerBot started. Trigger key: {TRIGGER_KEY}")
logging.info(f"{Fore.GREEN}TriggerBot started, trigger key: {TRIGGER_KEY}")

while True:
try:
Expand Down

0 comments on commit 5fc95b8

Please sign in to comment.