{"id":22883636,"url":"https://github.com/deadbits/slackbot-framework","last_synced_at":"2025-03-31T16:54:14.031Z","repository":{"id":144910337,"uuid":"62523013","full_name":"deadbits/slackbot-framework","owner":"deadbits","description":"Python slack bot framework","archived":false,"fork":false,"pushed_at":"2017-02-16T01:55:24.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T22:16:12.370Z","etag":null,"topics":["bot","python","python-library","slackbot"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/deadbits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-04T01:27:41.000Z","updated_at":"2018-10-24T16:48:00.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0f0426d-53a1-4cd3-9f59-240177140044","html_url":"https://github.com/deadbits/slackbot-framework","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/deadbits%2Fslackbot-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fslackbot-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fslackbot-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/deadbits%2Fslackbot-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/deadbits","download_url":"https://codeload.github.com/deadbits/slackbot-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246500712,"owners_count":20787742,"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":["bot","python","python-library","slackbot"],"created_at":"2024-12-13T18:39:28.717Z","updated_at":"2025-03-31T16:54:14.006Z","avatar_url":"https://github.com/deadbits.png","language":"Python","readme":"[![SayThanks](https://img.shields.io/badge/Say%20Thanks-!-1EAEDB.svg?style=flat)](https://saythanks.io/to/deadbits)  [![Donate](https://img.shields.io/badge/donate-BTC-blue.svg?style=flat)](https://www.coinbase.com/deadbits)\n\n# slackbot-framework\nPython library for a Slack bot.  \n\n## Description\nThis is a Python library that allows you to build your own Slack bot with relatively little effort.  \nThe class is based on the Gendo project but includes some more bells and whistles.\n(https://github.com/nficano/gendo)\n  \nTo create a bot you need a Slack bot token and then simply import the class. The next section details how to create\ncommands. Once your commands are all set, just call `SlackBot.run()` and your bot will have a long and merry existence. \n\n## Triggers  \nThe class has three different means of listening for messages:\n- exact\n    - Message must exactly match the trigger string\n- command\n    - Message must match trigger string and accepts arguments via regex pattern matching\n- listen\n    - Trigger string can be contained anywhere in the message\n\nTo use these listeners, simply add the appropriate decorator to your command function.  \nThe decorator function *must* accept the arguments `user` and `message` as the first and second arguments, respectively.  \n\nAnything returned from the decorated function will be sent back to the calling Slack channel or user. This should\n*always* be a string or stuff will break.  \n\n\n## Target Users and Channels\nCommand responses can be sent directly to a specific user or channel by using the decorator options `target_channel` and `target_user`.\n  \n```\n@bot.exact('!help', target_channel=\"main\")\n\n@bot.exact('!annoy', target_user=\"someone you dont like\")\n```\n\n\n## Trigger Examples\n*exact*  \n```\nfrom bot import SlackBot\nconf = {'username': 'my_bot'}\nbot = SlackBot(token='my token', config=conf)\n\n@bot.exact('!help')\ndef cmd_help(user, message):\n    return '{user.name} sent the !help command.'\n```\n\n*command*\nAny matching content from the message will be sent to the decorator function as additional arguments.  \nUsing regex match groups will send each group as it's own argument, as shown in the example below:\n  \n```\nsearch_re = re.compile(r'(.*)\\s(.*)')\n\n@bot.command('!search', match=search_re)\ndef cmd_search(user, message, key, value):\n    return 'attempting to search for %s:%s' % (key, value)\n```\n\n*listen*\n```\n@bot.listen('tacos')\ndef cmd_tacos(user, message):\n    return 'I love tacos too!'\n```\n\n## User argument\nThe `user` argument will be the calling Slack users ID. The ID is *not* the user name but an unique identifier Slack\nuses per user.\n  \nIf you wish to include the calling users name in the response, place `{user.name}` in the returned string. The bot will replace this with the username.\n\n## Message argument\nThe message argument is the raw message that the calling user sent to the bot.\n\n## Access Control\nBy adding Slack usernames to the 'admins' list in the bot config, you can then enforce access control on specific\ncommands.  \n\nWhen adding the trigger decorator, simply add the argument `admin_only=True` to the decorator options and this will\nrestrict that command to be only executed by admin users. If the Slack user is not an admin, the\ndecorator function will not get called, so you only need to add code to the function that should execute upon\nsuccessful authorization.\n\n```\n@bot.exact('!admin', admin_only=True)\ndef cmd_admin(user, message):\n    return '{user.name} is a valid admin.'\n```\n\n## Uploading snippets\nLike the `{user.name}`, bots can create Slack snippet by including the `{upload}` string in a returned command response.  \n  \nYou can also add a comment to the snippet by including the following:  \n`{comment.start:\"your comment here\":comment.end}`  \n\nAny other data in the command response is assumed to be the snippet content.\n  \nIn the example below, a snippet would be created with the content \"helllooooo world!\" and the comment \"whatever\".\n```\nreturn '{upload} {comment.start:\"whatever\":comment.end} helllooooo world!'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadbits%2Fslackbot-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeadbits%2Fslackbot-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeadbits%2Fslackbot-framework/lists"}