Skip to content

Instantly share code, notes, and snippets.

@seratch
Last active February 5, 2022 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seratch/cad385de1ca07cb3c63bc5408ba66823 to your computer and use it in GitHub Desktop.
Save seratch/cad385de1ca07cb3c63bc5408ba66823 to your computer and use it in GitHub Desktop.
Hot-reloading Socket Mode app using Jurigged (Python) - `SLACK_LOCAL_DEV=1 python app.py`
# You can run this script by `SLACK_LOCAL_DEV=1 python app.py`
import os
if os.environ.get("SLACK_LOCAL_DEV") == "1":
# Hot reloading https://github.com/breuleux/jurigged
import jurigged
jurigged.watch()
# Debug logging
import logging
logging.basicConfig(level=logging.DEBUG)
# https://slack.dev/bolt-python/tutorial/getting-started
from slack_bolt import App
app = App(token=os.environ["SLACK_BOT_TOKEN"])
@app.command("/hello")
def handle_some_command(ack, context):
ack(f":wave: Hi there! <@{context.user_id}>")
if __name__ == "__main__":
from slack_bolt.adapter.socket_mode import SocketModeHandler
SocketModeHandler(app, os.environ["SLACK_APP_TOKEN"]).start()
display_information:
name: socket-mode-app
features:
bot_user:
display_name: socket-mode-app
always_online: true
slash_commands:
- command: /hello
description: Say hello to the app
usage_hint: Hit it
oauth_config:
scopes:
bot:
- app_mentions:read
- commands
- chat:write
settings:
event_subscriptions:
bot_events:
- app_mention
interactivity:
is_enabled: true
socket_mode_enabled: true
[tool.poetry]
name = "socket-mode"
version = "0.1.0"
description = "Hot-reloading Socket Mode app using Jurigged"
authors = ["Kazuhiro Sera"]
[tool.poetry.dependencies]
python = "^3.9"
slack-bolt = "^1.11.4"
jurigged = "^0.4.1"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment