From 3668389d2f5144033dd5cd3e8ae4a945a92a0dfd Mon Sep 17 00:00:00 2001 From: Guilherme Brandt Date: Tue, 26 Feb 2019 21:41:26 -0300 Subject: [PATCH] Flashbang com arquivo --- danger.yml | 4 ++-- god/cli.py | 4 +++- god/config.py | 9 +++++---- god/handler.py | 6 +++++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/danger.yml b/danger.yml index 9dc25e0..26a7013 100644 --- a/danger.yml +++ b/danger.yml @@ -1,3 +1,4 @@ +--- #------------------------------------------------------------------------------- #=============================================================================== # * danger.yml #=============================================================================== @@ -9,7 +10,6 @@ #=============================================================================== #------------------------------------------------------------------------------- # Lista de processos que serão fechados (.exe é opcional) -#------------------------------------------------------------------------------- kill: - mspaint - chrome @@ -25,4 +25,4 @@ cmd: #------------------------------------------------------------------------------- # Flashbang: Abre um bloco de notas maximizado, pra esconder a tela #------------------------------------------------------------------------------- -flashbang: false \ No newline at end of file +flashbang: false diff --git a/god/cli.py b/god/cli.py index 957feba..af1f024 100644 --- a/god/cli.py +++ b/god/cli.py @@ -68,7 +68,9 @@ def print_settings(): for key in config.keys(): value = config.get(key) - print("\t", key, Fore.CYAN + ':' + Fore.RESET, " \t", value, sep='') + print( + "\t", (key + Fore.CYAN + ':' + Fore.RESET).ljust(40), value, + sep='') print(flush=True) diff --git a/god/config.py b/god/config.py index 7c5bf40..fbe7173 100644 --- a/god/config.py +++ b/god/config.py @@ -8,9 +8,10 @@ import yaml _DEFAULTS = { - "psname": "notepad.exe", + "flashbang_file": None, + "frequency": 30, "threshold": 1, - "frequency": 30 + "psname": "notepad.exe" } _config = {} @@ -23,14 +24,14 @@ def load(cfg_file="config.yml"): return global _config - with open(cfg_file, "r") as file: + with open(cfg_file, "r", encoding="utf8") as file: _config = yaml.load(file) or _config def save(cfg_file="config.yml"): """Salva as configurações para um arquivo""" - with open(cfg_file, 'w') as file: + with open(cfg_file, 'w', encoding="utf8") as file: yaml.dump(_config, file, default_flow_style=False) diff --git a/god/handler.py b/god/handler.py index b0b1b95..9ec8a16 100644 --- a/god/handler.py +++ b/god/handler.py @@ -6,6 +6,7 @@ """ import os +import json import yaml import win32con @@ -14,6 +15,7 @@ import win32process import god +import god.config as config import god.cli as cli import god.log as log @@ -25,12 +27,14 @@ def flashbang_notepad(): """ + file = config.get("flashbang_file") + start_info = win32process.STARTUPINFO() start_info.dwFlags = win32con.STARTF_USESHOWWINDOW start_info.wShowWindow = win32con.SW_MAXIMIZE win32process.CreateProcess( None, - "notepad", + f"notepad {file}" if file else "notepad", None, None, False,