slackapi / slackapi/bolt-python
Add support for "sub apps"
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 1.3k
- 派生
- 288
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 10
描述
When creating a large slack application it would be nice to be able to reuse components in a more pythonic way than what is possible right now.
A workaround is described in issue #236, but it requires passing the app object around and manually wiring up things by registering and calling decorators as functions directly.
I suggest adding a feature much like include_router in FastAPI or add_typer in Typer.
This feature will let us create sub-apps in separate files or even separate packages, like plugins that can be published on pypi.org separately.
Here is a small example illustrating what I mean:
main.py
Here is our main app, where we add a plugin from a separate package
import os
from slack_bolt import App
from my_plugin import my_plugin
# Initializes your app with your bot token and signing secret
app = App(
token=os.environ.get("SLACK_BOT_TOKEN"),
signing_secret=os.environ.get("SLACK_SIGNING_SECRET")
)
app.add_app(my_plugin)
my_plugin.py
A simple plugin that just creates a slack_bolt app, but without any config
from slack_bolt import App
my_plugin = App()
@my_plugin.message("hello")
def message_hello(message, say):
say("Hello world")
Category
- slack_bolt.App and/or its core components
- slack_bolt.async_app.AsyncApp and/or its core components
- Adapters in slack_bolt.adapter
- Others
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先查看 slack_bolt.App 和 slack_bolt.async_app.AsyncApp 的组合 API,然后阅读 issue #236 中描述的 workaround。将所请求的 add_app 行为与 FastAPI 的 include_router 和 Typer 的 add_typer 进行比较。当独立定义的子应用或插件可以附加到两种 app 变体,而无需手动传递父 app 或直接调用装饰器时,工作即告完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100