Skip to content

Proposal: Add support for decorator-based CommandModule command declaration #137

@richteer

Description

@richteer

I see a lot of other python frameworks use decorators to define commands, routes, etc. I think it would be a good extension to include that in our framework as well, and may simplify some of the boilerplate for module developers.

Something like the following would be nice:

class TestModule(CommandModule):

    @command("test")
    def test_(self, msg=msg):
        self.reply(msg, body="Test!")

Here, the pair ("test", self.test_) would be automatically added to the module's self.commands dict, without needing to declare it in self.init() first.

Ideally, this should work with chaining other decorators, like hasPermission and AsArgs, as the command dec should not touch the parameters at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions