Package: slack-machine
Slack MachineSlack Machine is a simple, yet powerful and extendable Slack bot framework. More than just a bot, Slack
Machine is a framework that helps you develop your Slack workspace into a ChatOps powerhouse. Slack Machine is built
with an intuitive plugin system that lets you build bots quickly, but also allows for easy code organization. A
plugin can look as simple as this:frommachine.plugins.baseimportMachineBasePluginfrommachine.plugins.messageimportMessagefrommachine.plugins.decoratorsimportrespond_toclassDeploymentPlugin(MachineBasePlugin):"""Deployments"""@respond_to(r"deploy (?P<application>\w+) to (?P<environment>\w+)")asyncdefdeploy(self,msg:Message,application,environment):"""deploy <application> <environment>: deploy application to target environment"""awaitmsg.say(f"Deploying{application}to{environment}")Breaking ChangesPlugin initialization is now async(v0.35.0)The optional initialization methodplugins can implement, which is
run once when the plugin is loaded, should be anasyncmethod starting the upcomingv0.35.0. The reason for this is that this
allows plugins to interact with Slack through the Slack Machine's plugin API - most of which methods are async.Simply prefix yourinit()methods withasync.Dropped support for Python 3.7(v0.34.0)As ofv0.34.0, support for Python 3.7 has been
dropped. Python 3.7 has reached end-of-life on 2023-06-27.AsyncIO(v0.30.0)As ofv0.30.0Slack Machine dropped support for
the old backend based on the RTM API. As such, Slack Machine is now fully based onAsyncIO. This means plugins written before the rewrite to asyncio
aren't supported anymore. Seeherefor a migration guide to
get your old plugins working with the new version of Slack Machine.It's really easy!FeaturesGet started with mininal configurationBuilt on top of theSlack Events APIfor smoothly responding
to events in semi real-time. UsesSocket Modeso your bot doesn't
need to be exposed to the internet!Support for rich interactions using theSlack Web APIHigh-level API for maximum convenience when building pluginsLow-level API for maximum flexibilityBuilt on top ofAsyncIOto ensure good performance by handling
communication with Slack concurrentlyPlugin API features:Listen and respond to any regular expressionRespond to Slash CommandsCapture parts of messages to use as variables in your functionsRespond to messages in channels, groups and direct message conversationsRespond with reactionsRespond in threadsRespond with ephemeral messagesSend DMs to any userSupport forblocksSupport formessage attachments[Legacy 🏚]Listen and respond to anySlack eventsupported by the Events APIStore and retrieve any kind of data in persistent storage (currently Redis, DynamoDB, SQLite and in-memory storage are
supported)Schedule actions and messagesEmit and listen for eventsHelp texts for PluginsComing SoonSupport for Interactive Buttons... and much moreInstallationYou can install Slack Machine using pip:$pipinstallslack-machineor add it to yourPoetryproject:poetryaddslack-machineIt isstrongly recommendedthat you installslack-machineinside avirtual environment!UsageCreate a directory for your Slack Machine bot:mkdir my-slack-bot && cd my-slack-botAdd alocal_settings.pyfile to your bot directory:touch local_settings.pyCreate a new app in Slack:https://api.slack.com/appsChoose to create an app from anApp manifestCopy/paste the following manifest:manifest.yamlAdd the Slack App and Bot tokens to yourlocal_settings.pylike this:SLACK_APP_TOKEN = "xapp-my-app-token"
SLACK_BOT_TOKEN = "xoxb-my-bot-token"Start the bot withslack-machine...Profit!DocumentationYou can find the documentation for Slack Machine here:https://dondebonair.github.io/slack-machine/Go read it to learn how to properly configure Slack Machine, write plugins, and more!