{"id":22901732,"url":"https://github.com/eguven/slack-machine-plugins","last_synced_at":"2025-05-08T02:10:42.756Z","repository":{"id":57468229,"uuid":"341031000","full_name":"eguven/slack-machine-plugins","owner":"eguven","description":"Utility plugins for Slack-Machine, the sexy, simple, yet powerful and extendable Slack bot","archived":false,"fork":false,"pushed_at":"2021-02-22T01:18:10.000Z","size":10,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-13T04:46:51.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eguven.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-02-21T23:55:07.000Z","updated_at":"2022-09-09T12:57:55.000Z","dependencies_parsed_at":"2022-09-19T09:31:11.452Z","dependency_job_id":null,"html_url":"https://github.com/eguven/slack-machine-plugins","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eguven%2Fslack-machine-plugins","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eguven%2Fslack-machine-plugins/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eguven%2Fslack-machine-plugins/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eguven%2Fslack-machine-plugins/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eguven","download_url":"https://codeload.github.com/eguven/slack-machine-plugins/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229514185,"owners_count":18085078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T01:40:41.519Z","updated_at":"2024-12-14T01:40:42.076Z","avatar_url":"https://github.com/eguven.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# slack-machine-plugins\n\nUtility plugins for Slack-Machine, the sexy, simple, yet powerful and extendable Slack bot.\n\n```shell\npip install slack-machine-plugins\n```\n\n## commander\n\nCommander provides two classes ``Command`` and ``CommandArgument`` for a declarative way to define chat commands and their arguments for input validation and error feedback for the user. Features include:\n\n* Type and length validation for chat command arguments.\n* Strict choices.\n* Custom validation and error messages.\n* Usage and error texts for user feedback.\n\n### Example Usage\n\nTaken from test case, realistic example.\n\n```python\n# command definition\n####################\nfrom machine_plugins.commander import Command, CommandArgument\n\nscale_cmd = Command(\n    name='scale',\n    description='Scale a deployment.',\n    arguments=[\n        CommandArgument(\n            name='namespace',\n            target_type=str,\n            choices=['default', 'dev'],\n            description='Namespace of the deployment.',\n        ),\n        CommandArgument(\n            name='deployment',\n            validation=(lambda d: d.startswith('deployment-prefix-'),),\n            description='Name of the deployment.',\n        ),\n        CommandArgument(\n            name='replicas',\n            target_type=int,\n            validation=(lambda r: 2 \u003c= int(r) \u003c= 10, 'You can not scale under 2 or above 10 replicas.'),\n        ),\n    ],\n)\n\n# command usage in slack-machine\n################################\nfrom machine.plugins.base import MachineBasePlugin\nfrom machine.plugins.decorators import respond_to\n\n\nclass DeploymentPlugin(MachineBasePlugin):\n\n    @respond_to(regex=r'^scale ?(?P\u003cargs\u003e.*)$')\n    def scale(self, msg, args):\n        errs = scale_cmd.errors(args)\n        if errs:\n            resp = '\\n'.join(errs)\n            msg.say(f'```{resp}```')\n            return\n        # input validation complete, do your thing e.g `scale(*args.split())`\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feguven%2Fslack-machine-plugins","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feguven%2Fslack-machine-plugins","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feguven%2Fslack-machine-plugins/lists"}