Skip to content

Only pass command arguments as message to commands #44

@pmayd

Description

@pmayd

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    InternalChanges not directly visible to the user: speed improvements, unit tests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions