是否可以使用RocketChat API(RocketChat Rest API)从我的RocketChat帐户向另一个帐户发送直接消息?
我查看了API文档,但没有找到我需要的内容。
答案 0 :(得分:1)
我使用下面的代码:
let RocketChat = require('rocketchat-nodejs').Client;
let Client = new RocketChat({
host: 'myHost',
port: 80,
scheme: 'http',
username: 'myUser',
password: 'myPass'
});
let Authentication = Client.Authentication();
let Users = Client.Users();
let Chat = Client.Chat();
Client.login().then(() => {
Authentication.me().then((result) => {
Users.list({ userId: 'muUser' }).then((result) => {
var list = result;
Chat.postMessage({ roomId: list.users[0]._id, text: 'test'})
.then((result) => {
})
});
});
}).catch((error) => {
console.log(error);
});