From c7a4c2a5ffd546ed1b1ceb5e05492396ed988bd4 Mon Sep 17 00:00:00 2001 From: core-hacked Date: Mon, 20 Dec 2021 19:28:58 +0100 Subject: [PATCH] Fix rookie mistake :ambulance: :alien: Release stable: 1.1.0 with the new ``-o / --output`` argument and fix if statement from ``fourtytwo == "foo" or "bar"`` to ``fourtytwo == "meaning of life" or fourtytwo == "42"`` :alien: :snake: Also update readme Thx mrx for help :+1: Co-Authored-By: mrx <70950846+mrx-rx@users.noreply.github.com> --- README.md | 2 +- main.py | 39 ++++++++++++--------------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index cc633bb..6c79d26 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ To get a local copy up and running follow these simple steps. # -p or --prefix [prefix] | Specify a prefix (for double word prefix' or ones with special char's use quotes) # -b or --heartbeat [int] | Specify the heartbeat timeout # -s or --serverpurge [prefix] | Specify a prefix for a server purge or leave blank for default - # (W.I.P) -n or --nooutput [bool (True/False)] | Specify if you want console output of each deleted message (true by default) + # -o or --output | Specify if you want to output deleted messages in the console # -h or --help | to view this in the terminal/console ``` Then in discord type your prefix or the default ``#DEL`` or ``#PS`` to purge messages from an entire server diff --git a/main.py b/main.py index b9da489..9cc7121 100644 --- a/main.py +++ b/main.py @@ -44,7 +44,7 @@ async def on_message(self, message): parser.add_argument('-p','--prefix', dest='prefix', type=str, help='Prefix to use with message purger') parser.add_argument('-s','--serverpurge', dest='serverpurge', type=str, help='Specify a prefix to use for Server Purge') parser.add_argument('-b','--heartbeat', dest='heartbeat', type=int, help='Heartbeat timeout to use') -parser.add_argument('-n','--nooutput', dest='nooutput', type=str, help='Enable console output of deleted messages (Good for debugging)') +parser.add_argument('-o', '--output', action='store_true', help='Enable console output of deleted messages (Good for debugging)') args = parser.parse_args() # Token @@ -52,37 +52,27 @@ async def on_message(self, message): token = args.token # Prefix - if args.prefix is not None: prefix = args.prefix else: prefix = "#DEL" # Serverpurge prefix - if args.serverpurge is not None: serverpurge = args.serverpurge else: serverpurge = "PS" # Hearbeat - if args.heartbeat is not None: heartbeat = args.heartbeat else: heartbeat = 86400 -# No console output / log +# output + if args.output == True: + nooutput = False - if args.nooutput is not None: - if args.nooutput == "f" or "F" or "false" or "False" or "FALSE" or "n" or "N" or "No" or "NO": - nooutput = bool(False) - elif args.nooutput == "t" or "T" or "true" or "True" or "TRUE" or "y" or "Y" or "Yes" or "YES": - nooutput = bool(True) - else: - nooutput = bool(True) - else: - nooutput = True else: token = input("Please input a Token: ") # Prefix @@ -106,20 +96,15 @@ async def on_message(self, message): heartbeat = input("Please input a heartbeat timeout (leave blank for the default 86400): ") if heartbeat == "": heartbeat = 86400 -# No console output / log - if args.nooutput is not None: - if args.nooutput == "f" or "F" or "false" or "False" or "FALSE" or "n" or "N" or "No" or "NO": - nooutput = bool(False) - elif args.nooutput == "t" or "T" or "true" or "True" or "TRUE" or "y" or "Y" or "Yes" or "YES": - nooutput = bool(True) - else: - nooutput = bool(True) +# output + if args.output == True: + nooutput = False else: - nooutputstr = input("Do you want to log deleted messages to console (Y/N): ") - if nooutputstr == "n" or "N" or "No" or "NO": - nooutput = bool(True) - elif nooutputstr == "y" or "Y" or "Yes" or "YES": - nooutput = bool(False) + nop = input("Do you want to log console output? (Y/N): ") + if nop == "" or nop == "n" or nop == "N" or nop == "No" or nop == "NO": + nooutput = True + elif nop == "y" or nop == "Y" or nop == "Yes" or nop == "YES": + nooutput = False # Run the self-bot and await prefix