Last active
October 2, 2024 05:48
-
-
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`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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