创建自定义自动化

你需要像安装其他 Discourse 插件一样安装它:在 Discourse 中安装插件。所以你会安装 Automation 插件并安装你添加自定义脚本的插件。它之所以能工作,是因为这里定义的方法:https://github.com/discourse/discourse-automation/blob/main/lib/plugin/instance.rb。在我上面发布的示例代码中,你会看到自定义脚本是通过调用 add_automation_scriptable 来添加的。

注意:不要安装我 GitHub 仓库中的示例自动化,仅将其作为如何扩展 Automation 插件的示例。(我忘了我在这里链接了它,并已更新,使其仅与我 fork 的 Discourse Automation 插件版本一起使用。但我链接到这里的代码仍然有效:Create custom Automations - #6 by simon automation-script-example 插件,使其无需我 fork 的 Automation 插件版本所做的更改即可工作。)

我的担忧是没有根据的。这个条件不是必需的:

if automation.script == "user_update_summary_email_options" && (context["kind"] == "user_added_to_group" || context["kind"] == "user_removed_from_group")

我将很快更新示例。

4 个赞