Added Command Support
This commit is contained in:
parent
1519e87859
commit
dadf75364e
@ -14,6 +14,7 @@ class AbstractCommand(metaclass=ABCMeta):
|
||||
|
||||
class CommandType(Enum):
|
||||
NONE = auto()
|
||||
Praxis = auto()
|
||||
TWITCH = auto()
|
||||
DISCORD = auto()
|
||||
|
||||
|
||||
@ -1,19 +1,27 @@
|
||||
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...")
|
||||
while True:
|
||||
inputLoop = True
|
||||
while inputLoop:
|
||||
keyboardInput = input()
|
||||
|
||||
if "exit" or "quit" or "stop" in keyboardInput:
|
||||
if "exit" in keyboardInput:
|
||||
print("Quitting User Module Interface...")
|
||||
break
|
||||
|
||||
@ -26,11 +34,41 @@ class User_Module():
|
||||
pass
|
||||
|
||||
def isCommand(self, input):
|
||||
isCommand = False
|
||||
isCommand = True
|
||||
#MAKE THIS
|
||||
return isCommand
|
||||
|
||||
def runCommand(self, input):
|
||||
pass
|
||||
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()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user