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

Only pass command arguments as message to commands #44

Open
pmayd opened this issue Sep 8, 2020 · 0 comments
Open

Only pass command arguments as message to commands #44

pmayd opened this issue Sep 8, 2020 · 0 comments
Labels
Internal Changes not directly visible to the user: speed improvements, unit tests

Comments

@pmayd
Copy link
Collaborator

pmayd commented Sep 8, 2020

Currently, each command gets the complete user text as message:

def perform_bot_cmd(msg, private=True):
    """Parses message and perform valid bot commands"""  
    # ...
    text = msg.get("text")
    # ...
    kwargs = {"user_id": user_id, "channel": channel_id, "text": text}
    return command(**kwargs)

But msg.get("text") contains the complete user input, which is for karmabot always @karmabot command <argument>. This leads to unnecessary parsing of this text in each command function that needs the optional argument. So each command has to split the text and determine if there is a third optional argument part. I suggest simplifying the API and pass as text only the third part, that is, the command argument. This is None if None was given and a text otherwise.

@pogross pogross added the Internal Changes not directly visible to the user: speed improvements, unit tests label Sep 8, 2020
@pogross pogross linked a pull request Sep 9, 2020 that will close this issue
@pogross pogross changed the title [Improvement] Only pass command arguments as message to commands Only pass command arguments as message to commands Sep 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Internal Changes not directly visible to the user: speed improvements, unit tests
Projects
None yet
Development

No branches or pull requests

2 participants