Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
qadoc.txt
reminder.txt
*.pyc
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
167 changes: 90 additions & 77 deletions cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

commands = {
"help": {
"command": "helpcmd",
"service": "helps",
"child": "main",
"arguments": "",
"desc": "This sends you to this page!"
},
Expand All @@ -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!"
},
Expand All @@ -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():
Expand Down Expand Up @@ -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

Expand All @@ -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":
Expand All @@ -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():
Expand All @@ -222,4 +177,62 @@ def remindercmd():

def update():
os.system("git pull")
print("[INFO] Code has been updated, please restart your instance.")
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
}
10 changes: 5 additions & 5 deletions connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
18 changes: 9 additions & 9 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@
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
if user_input[0] == "/":
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

Expand Down
1 change: 1 addition & 0 deletions qadoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 0 additions & 1 deletion reminder
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
Change this reminder by using the /reminder command!
10 changes: 5 additions & 5 deletions service-list
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
helpcmd-enabled
mathcmd-disabled
timecmd-enabled
sqrtcmd-enabled
remindercmd-enabled
helps-enabled
maths-enabled
times-enabled
reminders-enabled
updates-disabled