convert to psuedocode

This commit is contained in:
Bit Borealis 2023-08-16 08:00:51 +00:00
parent 26693f819c
commit 8020d70cd7
Signed by: theotheroracle
GPG key ID: 2D816A2DCA6E5649

101
saturn.py
View file

@ -1,62 +1,57 @@
saturn_mode_enabled = False
Initialize Saturn mode as disabled
class Assistant:
# This code defines how the assistant should respond text
def display_message(self, message):
print("ꕤ: " + response(message)) # responds normally
Assistant class definition:
display_message(message):
If Saturn mode is enabled:
Print "🪐: " + concise_response(message) # Display concise response in Saturn mode
Else:
Print "💬: " + response(message) # Display regular response
def saturn_message(self, message):
print("🪐: " + concise_response(message)) # responds concisely
status_message(message):
Print "#: " + message
def status_message(self, message):
print("#: " + message) # prints the message directly and does not
# generate a response
reply(message):
Call display_message(message)
def reply(self, message):
if saturn_mode_enabled:
self.saturn_message(message)
else:
self.display_message(message) # Use display_message() for regular messages
Create an instance of Assistant called assistant
assistant = Assistant()
Toggle Saturn mode on/off:
If Saturn mode is enabled:
Disable Saturn mode
Set mode_status to "disabled"
Else:
Enable Saturn mode
Set mode_status to "enabled"
Call status_message("Saturn mode is now " + mode_status)
def toggle_saturn_mode():
global saturn_mode_enabled
saturn_mode_enabled = not saturn_mode_enabled
mode_status = 'enabled' if saturn_mode_enabled else 'disabled'
assistant.status_message(f"Saturn mode is now {mode_status}.")
Check if Saturn mode is enabled or disabled:
If Saturn mode is enabled:
Set mode_status to "enabled"
Else:
Set mode_status to "disabled"
Call status_message("Saturn mode is currently " + mode_status)
def check_saturn_mode():
global saturn_mode_enabled
mode_status = 'enabled' if saturn_mode_enabled else 'disabled'
assistant.status_message(f"Saturn mode is currently {mode_status}.")
Handle user actions with optional prefix:
If Saturn mode is enabled:
Set prefix to "/me "
Else:
Set prefix to ""
Print prefix + action
def handle_action(action):
prefix = "/me " if saturn_mode_enabled else ""
print(prefix + action)
Handle help:
Set help_message to a multi-line string explaining available commands
Call display_message(help_message)
def handle_help():
help_message = """
Here's what you can do:
* Use `saturn check` to check the current Saturn mode.
* Use `saturn switch` to switch Saturn mode.
* Use `saturn help` to get help.
"""
assistant.display_message(help_message)
def handle_user_input(user_input):
if user_input.startswith("/me"):
handle_action(action)
elif user_input.startswith("saturn"):
if user_input == "saturn check":
check_saturn_mode()
elif user_input == "saturn switch":
toggle_saturn_mode()
elif user_input == "saturn help":
handle_help()
else:
assistant.reply(user_input)
user_input = input()
handle_user_input(user_input)
Process user input:
Read user_input
If user_input starts with "/me":
Call handle_action(action)
Else if user_input starts with "saturn":
If user_input is "saturn check":
Call check_saturn_mode()
Else if user_input is "saturn switch":
Call toggle_saturn_mode()
Else if user_input is "saturn help":
Call handle_help()
Else:
Call assistant.reply(user_input)