Skip to content

Commit ba7af2c

Browse files
authored
Merge 0.3.1 with main branch
0.3.1 update introduces commands replacing the old system with repetitive if statements.
2 parents 94ac69d + 54a88db commit ba7af2c

4 files changed

Lines changed: 41 additions & 42 deletions

File tree

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ Lenny is a self-learning AI that can remember the answers to any question the us
44

55
So far Lenny is kind of useless because you need to know the answer to your question for Lenny to learn.
66

7-
### 0.3:30.10.20 updates:
8-
- Added time/date
9-
- Services and service handling
10-
- 2 new commands: `time` and `services`
7+
### 0.3.1 updates:
8+
- Added commands
9+
- Disabled mathcmd service by default
1110

1211
### Using Lenny
1312
1. Clone this repository

cmds/helpcmd.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def func():
22
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.")
33

4-
print("\nformat\ncommands\ninput markers\nmath\nservices\n")
4+
print("\nformat\ncommands\ninput markers\n")
55

66
while True:
77
user_input = input("[H] ")
@@ -14,7 +14,12 @@ def func():
1414
continue
1515

1616
if user_input == "commands":
17-
print("Since most answers to questions are created by you, the user, I'll only list down my built in commands.")
17+
print("I have some built in commands that you can use such as time and math!")
18+
print("You start all commands with a \"/\" and then the command. Below is a list of all my commands")
19+
print("/math - [ALPHA] This is still in development, but right now this is capable of doing basic math with only two numbers.")
20+
print("/help - This sends you to this page!")
21+
print("/services - Lists down all the services being used in this program, and gives you the option to disable/enable them")
22+
print("/time - Prints the time and date! Pretty nifty, huh?")
1823
continue
1924

2025
if user_input == "input markers":
@@ -24,16 +29,3 @@ def func():
2429
print(" [A] - answering input that will set whatever you write as the answer to your question")
2530
print(" [S] - service editing input")
2631
continue
27-
28-
if user_input == "math":
29-
print("So far I can only do basic math, like addition, subtraction, multiplication and division.")
30-
print("If you want me to calculate something for you, write in a question with 2 numbers with a math symbol (+, -, /, *)")
31-
continue
32-
33-
if user_input == "services":
34-
print("Services are the smaller functions that handle dynamic questions like math or this help page.")
35-
print("Some of my services are incomplete and are disabled by default to keep this program running smoothly.")
36-
print("If you want to disable or enable a service, type in the \"services\" command in a [~] input to view them all.")
37-
continue
38-
39-
print("I couldn't find the subject you're looking to find out more about! Maybe check for any typos?")

main.py

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@
1212

1313
print("Formatting and sorting QAs...")
1414

15+
# commands array
16+
cmds = [
17+
["help", "helpcmd"],
18+
["services", connect.list_processes],
19+
["time", "timecmd"],
20+
["math", "mathcmd"],
21+
["exit", exit],
22+
["quit", exit]
23+
]
24+
1525
# Removes the annoying \n in all the lines
1626
for file_line in file_lines:
1727
file_place = file_lines.index(file_line)
@@ -25,7 +35,7 @@
2535
answers.append(split_answer)
2636

2737
print("\nWelcome to Lenny! Version 0.3:30.10.20")
28-
print("To get started, type in any question! Type \"help\" to get more detailed instructions.\n")
38+
print("To get started, type in any question! Type \"/help\" to get more detailed instructions.\n")
2939

3040
while True:
3141
user_input = input("[~] ")
@@ -34,28 +44,26 @@
3444
# Built in functions (priority) so that user can't overwrite them
3545
if user_input == "exit" or user_input == "quit":
3646
exit()
37-
38-
if user_input == "help":
39-
connect.run_process("helpcmd")
40-
continue
4147

42-
math_symbols_replaced = user_input.replace("-", "+").replace("/", "+").replace("*", "+")
43-
math_symbol_split = math_symbols_replaced.split("+")
44-
45-
if len(math_symbol_split) > 1:
46-
left_input_length = len(math_symbol_split[0])
47-
input_operator = user_input[left_input_length]
48-
49-
connect.run_process("mathcmd", input_operator, math_symbol_split[0], math_symbol_split[1])
50-
continue
51-
52-
if user_input == "services":
53-
connect.list_processes()
54-
continue
55-
56-
if user_input == "whats the time" or user_input == "what is the time" or user_input == "time":
57-
connect.run_process("timecmd")
58-
continue
48+
# Command handling
49+
if user_input[0] == "/":
50+
foundResult = False
51+
52+
for cmd in cmds:
53+
if user_input[1:] == cmd[0]:
54+
if isinstance(cmd[1], str):
55+
connect.run_process(cmd[1])
56+
else:
57+
cmd[1]()
58+
59+
foundResult = True
60+
break
61+
62+
if foundResult == True:
63+
continue
64+
else:
65+
print("I don't think I have any commands that go by that name. Maybe try removing spaces or punctuation!")
66+
continue
5967

6068
# User-generated question/answer handling
6169
if user_input in questions:

service-list

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
helpcmd-enabled
2-
mathcmd-enabled
2+
mathcmd-disabled
33
timecmd-enabled

0 commit comments

Comments
 (0)