通过Slack API发送命令 [英] Sending command via 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屋!