通过Slack API发送命令 [英] Sending command via Slack API

查看:74
本文介绍了通过Slack API发送命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过API以编程方式将 command 发送到Slack?我已经使用

Is there a way to programmatically send a command to Slack via the API? I'm successfully posting a message using

var postingResponse = client.UploadValues("https://slack.com/api/chat.postMessage", 
                      "POST", new NameValueCollection() {
                            {"token","<token>"},
                            {"channel","<ID>"}, 
                            {"text", "/mycommand hello" },
                            {"username","<username>" },
                            {"link_names", "true" },
                            {"parse", "full" }
                       });

这很好用,但是/mycommand hello 只是打印为文本,而不是作为命令执行.我尝试添加一对 {"command","/mycommand hello"} ,但也没有任何反应.

This works well but the /mycommand hello is just printed as text instead of executing as a command. I tried adding a pair {"command", "/mycommand hello" } but nothing happened either.

谢谢

推荐答案

我没有亲自尝试过,但是根据此答案有未公开的API方法 chat.command 用于在公共频道中执行命令.还有一个用于向松弛发送命令的Python程序.

I did not try it out by myself, but according to this answer there is the undocumented API method chat.command for executing commands in public channels. There is also a Python program for sending commands to slack.

这篇关于通过Slack API发送命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆