Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The exact command not found #4

Open
DockCZ opened this issue Oct 22, 2019 · 0 comments
Open

The exact command not found #4

DockCZ opened this issue Oct 22, 2019 · 0 comments

Comments

@DockCZ
Copy link

DockCZ commented Oct 22, 2019

  • webexteamsbot version: 0.1.3.0
  • Python version: Python 3.6.8
  • Operating System: CentOS Linux 7 (Core)

Description

When I use bot.add_command and add some test command.
Like this: bot.add_command("test", "Test command", getTest)

Than if I send message to my bot where the command word is placed.
I get response for the command even if it is not exact command.

From DEBUG

Message content:
Webex Teams Message:
{
  "id": "",
  "roomId": "",
  "roomType": "direct",
  "text": "MyTest",
  "personId": "",
  "personEmail": "",
  "created": "2019-10-22T10:36:15.253Z"
}
Message from: 
Found command: test

Solution

From source:
webexteamsbot.py line 312 - 319

            # Find the command that was sent, if any
            command = ""
            for c in sorted(self.commands.items()):
                if message.text.lower().find(c[0]) != -1:
                    command = c[0]
                    sys.stderr.write("Found command: " + command + "\n")
                    # If a command was found, stop looking for others
                    break

My code:

            # Find the command that was sent, if any
            command = ""
            for c in self.commands.items():
                # Checking only for exact match
                if message.text.lower() == c[0]:
                    command = c[0]
                    sys.stderr.write("Found command: " + command + "\n")
                    # If a command was found, stop looking for others
                    break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant