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