79 lines
2.3 KiB
Python
79 lines
2.3 KiB
Python
import config as config
|
|
import db
|
|
import tts
|
|
|
|
import credentials
|
|
|
|
import commands.loader as command_loader
|
|
from commands.command_base import AbstractCommand
|
|
|
|
from cooldowns import Cooldown_Module
|
|
|
|
class User_Module():
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.dbCredential: credentials.DB_Credential
|
|
self.MessageLog:list = []
|
|
|
|
def main(self):
|
|
print("Waiting on User input...")
|
|
inputLoop = True
|
|
while inputLoop:
|
|
keyboardInput = input()
|
|
|
|
if "exit" in keyboardInput:
|
|
print("Quitting User Module Interface...")
|
|
break
|
|
|
|
self.parseInput(keyboardInput)
|
|
|
|
def parseInput(self, input):
|
|
if self.isCommand(input):
|
|
self.runCommand(input)
|
|
else:
|
|
pass
|
|
|
|
def isCommand(self, input):
|
|
isCommand = True
|
|
#MAKE THIS
|
|
return isCommand
|
|
|
|
def runCommand(self, input):
|
|
self.eval_commands(input)
|
|
|
|
def eval_commands(self, message):
|
|
# containsURL: bool = self.contains_url(message)
|
|
try:
|
|
#first_space_idx = message.text.index(' ')
|
|
|
|
# This fixes a error where if you send a command without arguments it fails because
|
|
# it cant find the substring.
|
|
if message.content.find(" ") != -1:
|
|
first_space_idx = message.content.index(' ')
|
|
else:
|
|
first_space_idx = -1
|
|
|
|
command_text = ' '
|
|
if first_space_idx > -1:
|
|
command_text = message.content[0:first_space_idx]
|
|
else:
|
|
command_text = message.content
|
|
|
|
command = self.commands[command_text]
|
|
if command is not None and command.command_type is AbstractCommand.CommandType.Praxis:
|
|
command.do_command(self, message)
|
|
except Exception as e:
|
|
# Undo the following for debug stuff
|
|
#print(e)
|
|
pass # we don't care
|
|
|
|
def tts_message(self, message):
|
|
tts.tts(message)
|
|
|
|
if __name__ == "__main__":
|
|
testModule = User_Module()
|
|
|
|
credentials_manager = credentials.Credentials_Module()
|
|
credentials_manager.load_credentials()
|
|
testModule.dbCredential = credentials_manager.find_DB_Credential(config.credentialsNickname)
|
|
testModule.main() |