diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..88caafb --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +qadoc.txt +reminder.txt +*.pyc \ No newline at end of file diff --git a/README.md b/README.md index dac1e39..b584414 100644 --- a/README.md +++ b/README.md @@ -9,13 +9,11 @@ ___ Check out the [Lenny Wiki](https://github.com/JKasCode/lenny-python/wiki) for update logs, commands and other info! ___ -### 0.3.4 updates: - - Improved commands dictionary - - Moved commands dictionary to `cmds.py` - - New editable reminder that prints when you start the program - - New commands: - - `/cmds` which opens the /help command but jumps to commands - - `/reminder` which allows you to edit the reminder +### 0.3.5 updates: + - Remade services + - `sqrt` is now a child service of `maths` + - New commands: `/rawtime` and `/update` + - First update using the command line!! ___ ### Using Lenny 1. Clone this repository diff --git a/cmds.py b/cmds.py index 283ebd4..fa2315a 100644 --- a/cmds.py +++ b/cmds.py @@ -5,7 +5,8 @@ commands = { "help": { - "command": "helpcmd", + "service": "helps", + "child": "main", "arguments": "", "desc": "This sends you to this page!" }, @@ -15,17 +16,26 @@ "desc": "Lists down all the services used in this program, and gives you the option to enable or disable them" }, "time": { - "command": "timecmd", + "service": "times", + "child": "display", "arguments": None, "desc": "Prints the time and date! Pretty nifty, huh?" }, + "rawtime": { + "service": "times", + "child": "rawdisplay", + "arguments": None, + "desc": "Prints the raw time in seconds" + }, "math": { - "command": "mathcmd", + "service": "maths", + "child": "calculator", "arguments": None, "desc": "[ALPHA] Doesn't really work for now but maybe someday soon it perhaps might be fixed!" }, "reminder": { - "command": "remindercmd", + "service": "reminders", + "child": "set", "arguments": None, "desc": "Command to edit the reminder note that pops up every time you start the program!" }, @@ -40,21 +50,23 @@ "desc": "Also stops the program. Exciting!" }, "sqrt": { - "command": "sqrtcmd", + "service": "maths", + "child": "sqrt", "arguments": None, "desc": "Brings up the custom kSquareRoot algorithm" }, "cmds": { - "command": "helpcmd", + "service": "helps", + "child": "main", "arguments": "commands", "desc": "Prints all the commands in a neat little list!" }, "update": { - "command": "update", + "service": "updates", + "child": "pull", "arguments": None, "desc": "Update the code!" } - } def print_commands(): @@ -87,47 +99,20 @@ def kSquareRoot(tested_num, repetitions): # KasCode's Square Root finder algorit return current_min + ( current_max - current_min ) / 2 -def sqrtcmd(): - tested_num = 0 - reps = 0 - - while True: - try: - tninput = input("Enter the number you want to find the square root of: ") - tninput = int(tninput) - except ValueError: - print("Make sure you're typing in a number!") - continue - else: - tested_num = tninput - break - - while True: - try: - tninput = input("Now enter the number of algorithm repetitions. Type \"help\" for more: ") - if tninput == "help": - print("This number is how many times this algorithm will repeat. The higher the number, the more accurate my result will be! I recommend around 5000-50000000 (A lot)") - continue - else: - tninput = int(tninput) - except ValueError: - print("Make sure you're typing in a number!") - continue - else: - reps = tninput - break - - result = kSquareRoot(tested_num, reps) - print("Result: "+str(result)) - def timecmd(): time = datetime.datetime.now() print("The time is " + time.strftime("%H") + ":" + time.strftime("%M")) print("Today is " + time.strftime("%A") + ", " + time.strftime("%d") + " " + time.strftime("%B")) +def rawtimecmd(): + time = datetime.datetime.now() + print(time) + + def helpcmd(jump): - print("\nI work by learning the answers to any question you have, then remembering them for later.\nFor more help, type in any of the subjects below for details.\nWhen you're done, type in \"exit\" to go back.") - print("\nformat\ncommands\ninput markers\n") + if not jump: + print("\nI work by learning the answers to any question you have, then remembering them for later.\nFor more help, type in any of the subjects below for details.\nWhen you're done, type in \"exit\" to go back.") + print("\nformat\ncommands\ninput markers\n") debounce = False @@ -153,41 +138,10 @@ def helpcmd(jump): print("You start all commands with a \"/\" and then the command. Below is a list of all my commands'\n") print_commands() - continue - if user_input == "input markers": - print("You might have noticed that when you're typing something in, theres a little box on the left. Here is a list of what they mean:") - print(" [~] - basic input where you write in a question") - print(" [H] - help page input for detail on subjects") - print(" [A] - answering input that will set whatever you write as the answer to your question") - print(" [S] - service editing input") - print(" [R] - reminder editing input") - continue + if jump == "commands": + break -def mathcmd(): - print("\nI work by learning the answers to any question you have, then remembering them for later.\nFor more help, type in any of the subjects below for details.\nWhen you're done, type in \"exit\" to go back.") - - print("\nformat\ncommands\ninput markers\n") - - while True: - user_input = input("[H] ") - - - if user_input == "exit": - break - - if user_input == "format": - print("I recommend that you don't add any punctuations such as ! or ?. I also don't really care whether you capitalize your sentences or not!") - continue - - if user_input == "commands": - print("I have some built in commands that you can use such as time and math!") - print("You start all commands with a \"/\" and then the command. Below is a list of all my commands") - print("/math - [ALPHA] This is still in development, but right now this is capable of doing basic math with only two numbers.") - print("/help - This sends you to this page!") - print("/services - Lists down all the services being used in this program, and gives you the option to disable/enable them") - print("/time - Prints the time and date! Pretty nifty, huh?") - print("/sqrt - Brings up the kSquareRoot function for finding the square root of the number you're looking for.") continue if user_input == "input markers": @@ -196,6 +150,7 @@ def mathcmd(): print(" [H] - help page input for detail on subjects") print(" [A] - answering input that will set whatever you write as the answer to your question") print(" [S] - service editing input") + print(" [R] - reminder editing input") continue def remindercmd(): @@ -222,4 +177,62 @@ def remindercmd(): def update(): os.system("git pull") - print("[INFO] Code has been updated, please restart your instance.") \ No newline at end of file + print("Code has been updated, please restart your instance.") + +def mathcmd(): + print("Calculator is currently not functioning.") + +def sqrtcmd(): + tested_num = 0 + reps = 0 + + while True: + try: + tninput = input("Enter the number you want to find the square root of: ") + tninput = int(tninput) + except ValueError: + print("Make sure you're typing in a number!") + continue + else: + tested_num = tninput + break + + while True: + try: + tninput = input("Now enter the number of algorithm repetitions. Type \"help\" for more: ") + if tninput == "help": + print("This number is how many times this algorithm will repeat. The higher the number, the more accurate my result will be! I recommend around 5000-50000000 (A lot)") + continue + else: + tninput = int(tninput) + except ValueError: + print("Make sure you're typing in a number!") + continue + else: + reps = tninput + break + + result = kSquareRoot(tested_num, reps) + print("Result: "+str(result)) + +maths = { + "calculator": mathcmd, + "sqrt": sqrtcmd +} + +helps = { + "main": helpcmd +} + +updates = { + "pull": update, +} + +reminders = { + "set": remindercmd +} + +times = { + "display": timecmd, + "rawdisplay": rawtimecmd +} diff --git a/connect.py b/connect.py index a6800c2..6870edc 100644 --- a/connect.py +++ b/connect.py @@ -13,13 +13,13 @@ service_names.append(split_service[0]) service_enabled.append(split_service[1].rstrip()) # Get rid of that annoying \n -def run_process(name, *args): - if name in service_names: - if service_enabled[service_names.index(name)] == "enabled": # Checks if the service is enabled +def run_process(service, child, *args): + if service in service_names: + if service_enabled[service_names.index(service)] == "enabled": # Checks if the service is enabled if len(args) > 0: - getattr(cmds, name)(*args) + getattr(cmds, service)[child](*args) else: - getattr(cmds, name)() + getattr(cmds, service)[child]() else: print("This service is disabled. Type the command \"services\" to enable it.") else: diff --git a/main.py b/main.py index 3f9733c..2a9ccf1 100644 --- a/main.py +++ b/main.py @@ -30,16 +30,16 @@ reminder = reminder_doc.read() if reminder == "": - reminder = "E" + reminder = "E" # dont ask why else: - print("Reminder: "+reminder+"\n") + print("Reminder: "+reminder.rstrip()+"\n") while True: user_input = input("[~] ") user_input = formatting.format_input(user_input) # Built in functions (priority) so that user can't overwrite them - if user_input == "exit" or user_input == "quit": + if user_input == "exit" or user_input == "quit" or user_input == "/exit" or user_input == "/quit": exit() # Command handling @@ -47,15 +47,15 @@ foundResult = False if user_input[1:] in cmds: - slashremoved = cmds[user_input[1:]] + sr = cmds[user_input[1:]] - if "connect" not in slashremoved["command"]: - if slashremoved["arguments"] == None: - connect.run_process(slashremoved["command"]) + if "command" not in sr: + if sr["arguments"] == None: + connect.run_process(sr["service"], sr["child"]) else: - connect.run_process(slashremoved["command"], slashremoved["arguments"]) + connect.run_process(sr["service"], sr["child"], sr["arguments"]) else: - getattr(connect, slashremoved["command"].replace("connect.", ""))() + getattr(connect, sr["command"].replace("connect.", ""))() foundResult = True diff --git a/qadoc b/qadoc index 5161f89..2923d4e 100644 --- a/qadoc +++ b/qadoc @@ -9,3 +9,4 @@ how are you~I'm doing fine, thanks! how old are you~As of right now, I am less than a year old. But remember, AI bots don't follow human age! what is your full name~Leonard L. Lenny. how long is a piece of string~As long as one end to it's middle doubled +wow~indeed diff --git a/reminder b/reminder index 799861e..e69de29 100644 --- a/reminder +++ b/reminder @@ -1 +0,0 @@ -Change this reminder by using the /reminder command! diff --git a/service-list b/service-list index d609045..d834881 100644 --- a/service-list +++ b/service-list @@ -1,5 +1,5 @@ -helpcmd-enabled -mathcmd-disabled -timecmd-enabled -sqrtcmd-enabled -remindercmd-enabled +helps-enabled +maths-enabled +times-enabled +reminders-enabled +updates-disabled \ No newline at end of file