DougDougGithub / TwitchPlays

Code that allows Twitch Chat or Youtube Chat to control a game

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow same user to send multiple same commands

DominicZ8 opened this issue · comments

Currently Twitch handles repeating commands like this:

  1. "down" = "down"
  2. "down" = "down [?]" (adds (?) after command, since it thinks it's spam)
  3. "down" = "down
  4. "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.

I dont think he's gonna see this
Doug_Thanos_(cropped)-1

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.

Source