问题
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" }
});
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.
Thanks
回答1:
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.
来源:https://stackoverflow.com/questions/45350521/sending-command-via-slack-api