Fixed No Substring/No Arguments Bug
Fixed an error where if a command without arguments is sent it would fail.
This commit is contained in:
parent
d00f01edc3
commit
5d97066b8b
@ -71,7 +71,15 @@ 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)
|
||||||
try:
|
try:
|
||||||
first_space_idx = message.text.index(' ')
|
#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.text.find(" ") != -1:
|
||||||
|
first_space_idx = message.text.index(' ')
|
||||||
|
else:
|
||||||
|
first_space_idx = -1
|
||||||
|
|
||||||
command_text = ' '
|
command_text = ' '
|
||||||
if first_space_idx > -1:
|
if first_space_idx > -1:
|
||||||
command_text = message.text[0:first_space_idx]
|
command_text = message.text[0:first_space_idx]
|
||||||
@ -82,29 +90,9 @@ class Twitch_Module():
|
|||||||
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
if command is not None and command.command_type is AbstractCommand.CommandType.TWITCH:
|
||||||
command.do_command(self, message)
|
command.do_command(self, message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
pass # we don't care
|
pass # we don't care
|
||||||
# if message.text.startswith('!tts start'):
|
|
||||||
# print("tts activated on #" + message.channel)
|
|
||||||
# self.send_message("tts activated")
|
|
||||||
# self.tts_enabled = True
|
|
||||||
#
|
|
||||||
# if message.text.startswith('!tts stop'):
|
|
||||||
# print("tts deactivated on #" + message.channel)
|
|
||||||
# self.send_message("tts deactivated")
|
|
||||||
# self.tts_enabled = False
|
|
||||||
#
|
|
||||||
# if message.text.startswith('!test'):
|
|
||||||
# print("!test Detected")
|
|
||||||
# message.chat.send("test acknowledged")
|
|
||||||
# # message.chat.send(f'@{message.user().display_name}, you have {message.user().view_count} views.')
|
|
||||||
|
|
||||||
# if message.text.startswith('!roll'):
|
|
||||||
# try:
|
|
||||||
# pass
|
|
||||||
# #self.dice_roll(message)
|
|
||||||
# except Exception:
|
|
||||||
# self.send_message("{something went wrong}")
|
|
||||||
# print("{something went wrong}")
|
|
||||||
|
|
||||||
def tts_message(self, message: twitch.chat.Message):
|
def tts_message(self, message: twitch.chat.Message):
|
||||||
if not self.contains_slur(message):
|
if not self.contains_slur(message):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user