#!/usr/bin/env python3 # warn: script only for unix based systems import json import requests with open("config.json", "r") as file: config = json.load(file) url_webhook = config.get("url_webhook", "").strip() user = config.get("user", "").strip() avatar = config.get("avatar", "").strip() # defaults to use later defaultuser = "Spooky Bot" if not user: user = defaultuser if not url_webhook: print("WARN: no url webhook found in config.json. Fallbacking to Direct Connect...") directconnect() debug_mode = True def readjsonopt(): print(f"Connected as '{user}'. Press Ctrl+C at any time to quit.\n") # Endless manual entry loop while True: message = input("\n> ") if not message: continue # Send the payload response = requests.post( url_webhook, json={ "content": message, "username": user, "avatar_url": avatar } ) if debug_mode == True: print(f"ans: {response.status_code}") def directconnect(): global user url_webhook = input("Webhook URL (*):\n").strip() while not url_webhook: print("You must include a webhook URL.") url_webhook = input("Webhook URL (*):\n").strip() if user == defaultuser: user = input("User (optional):\n ").strip() if not user: user = defaultuser print(f"Connected as {user}. Press CTRL+C to quit.") while True: message = input("\n> ") if not message: continue requests.post( url_webhook, json={ "content": message, "username": user, "avatar_url": avatar } ) def mainmenu(): banner = r""" _ _ _ _ __ _____| |__ | |__ ___ ___ | | _____ ___ _ __ __| | ___ _ __ \ \ /\ / / _ \ '_ \| '_ \ / _ \ / _ \| |/ / __|/ _ \ '_ \ / _` |/ _ \ '__| \ V V / __/ |_) | | | | (_) | (_) | <\__ \ __/ | | | (_| | __/ | \_/\_/ \___|_.__/|_| |_|\___/ \___/|_|\_\___/\___|_| |_|\__,_|\___|_| """ print(banner + "\n\n") print("1. Read JSON") print("2. Direct connect") opt = input("option: ") if opt == "1": readjsonopt() elif opt == "2": directconnect() if __name__ == "__main__": if not url_webhook: print("WARN: no url webhook found in config.json. Fallbacking to Direct Connect...") directconnect() mainmenu()