handled KeyError on unfound commands
better command_text finding
This commit is contained in:
parent
ee6e5bd0a6
commit
5b2c7c0ee9
@ -68,12 +68,19 @@ class Twitch_Module():
|
|||||||
|
|
||||||
def eval_commands(self, message: twitch.chat.Message):
|
def eval_commands(self, message: twitch.chat.Message):
|
||||||
# containsURL: bool = self.contains_url(message)
|
# containsURL: bool = self.contains_url(message)
|
||||||
command_text = message.text[0:message.text.index(' ')]
|
first_space_idx = message.text.index(' ')
|
||||||
|
command_text = ' '
|
||||||
command = self.commands[command_text]
|
if first_space_idx > -1:
|
||||||
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
command_text = message.text[0:first_space_idx]
|
||||||
command.do_command(self, message)
|
else:
|
||||||
|
command_text = message.text
|
||||||
|
|
||||||
|
try:
|
||||||
|
command = self.commands[command_text]
|
||||||
|
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
||||||
|
command.do_command(self, message)
|
||||||
|
except Exception as e:
|
||||||
|
pass # we don't care
|
||||||
# if message.text.startswith('!tts start'):
|
# if message.text.startswith('!tts start'):
|
||||||
# print("tts activated on #" + message.channel)
|
# print("tts activated on #" + message.channel)
|
||||||
# self.send_message("tts activated")
|
# self.send_message("tts activated")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user