Allow same user to send multiple same commands
DominicZ8 opened this issue · comments
Currently Twitch handles repeating commands like this:
- "down" = "down"
- "down" = "down [?]" (adds (?) after command, since it thinks it's spam)
- "down" = "down
- "down" = "down [?]"
to omit this I changed the code in TwitchPlays_TEMPLATE.py (line 62) so the msg variable works anyways:
def handle_message(message):
try:
msg = message['message'].lower()
chat_cmd = msg.split(" ")
if len(chat_cmd) > 1 and isinstance(chat_cmd[1], str) and len(chat_cmd[1]) > 1 and chat_cmd[1] not in ['right', 'up']:
print('ignore sentence')
else:
msg = chat_cmd[0]
Logic is:
if the command has multiple parts like "down [?]", split the string at the space and if the second part has only 1 character (like a "?") set msg = the first part before the space, so it counts as a valid command.
Additionally check if the second part after the space is longer than 1 character (could be a sentence in chat starting with a command word) ignore that by keeping the msg as is.
Honestly, I'd just create a PR and move on. He stated on the livestream where explained all of these he wouldn't be taking PRs, but it doesn't hurt to submit one anyway. Furthermore, if you haven't already, you can fork the repo and push this code to your fork.
Oops, I forgot
LGTM 👍
Honestly, I'd just create a PR and move on. He stated on the livestream where explained all of these he wouldn't be taking PRs, but it doesn't hurt to submit one anyway. Furthermore, if you haven't already, you can fork the repo and push this code to your fork.
same philosophy here. altho he seems to skim over PRs from time to time, merging the ones that look genuine and closing ones that look like jokes.