如何获取向 Circuit JavaScript SDK 中的机器人发送消息的用户的电子邮件?
How to get email of user who send message to bot in Circuit JavaScript SDK?
我正在创建一个机器人,它将在 Circuit 中接收消息,然后使用打印此消息的用户的电子邮件将其发送到其他地方。
例如我使用 xlator-bot https://github.com/circuit/xlator-bot
this.receiveItem = function receiveItem(item) {
logger.info('[APP]: receiveItem');
if (item.type !== 'TEXT' || self.sentByMe(item)) {
logger.debug('[APP]: skip it is not text or I sent it');
return;
}
if (!item.text || !item.text.content) {
logger.info('[APP]: skip it does not have text');
return;
}
self.receiveText(htmlToText.fromString(item.text.content))
.then (function addResponseItem(responseItem){
logger.info('[APP]: addResponseItem');
var comment = {
convId: item.convId,
parentId: (item.parentItemId) ? item.parentItemId : item.itemId,
content: responseItem
};
return client.addTextItem(item.convId, comment);
})
.catch(function(e){
logger.error('[APP]:', e);
});
};
我想获取在此函数中发送项目的用户的电子邮件作为字符串变量。谁能建议我该怎么做?
item
有一个属性 creatorId
,它是发件人的用户 ID。 API getUserById
将 return 包含 emailAddress
属性的用户对象。
见
https://circuitsandbox.net/sdk/classes/Item.html#property_creatorId and https://circuitsandbox.net/sdk/classes/Client.html#method_getUserById 和
https://circuitsandbox.net/sdk/classes/User.html#property_emailAddress
我正在创建一个机器人,它将在 Circuit 中接收消息,然后使用打印此消息的用户的电子邮件将其发送到其他地方。
例如我使用 xlator-bot https://github.com/circuit/xlator-bot
this.receiveItem = function receiveItem(item) {
logger.info('[APP]: receiveItem');
if (item.type !== 'TEXT' || self.sentByMe(item)) {
logger.debug('[APP]: skip it is not text or I sent it');
return;
}
if (!item.text || !item.text.content) {
logger.info('[APP]: skip it does not have text');
return;
}
self.receiveText(htmlToText.fromString(item.text.content))
.then (function addResponseItem(responseItem){
logger.info('[APP]: addResponseItem');
var comment = {
convId: item.convId,
parentId: (item.parentItemId) ? item.parentItemId : item.itemId,
content: responseItem
};
return client.addTextItem(item.convId, comment);
})
.catch(function(e){
logger.error('[APP]:', e);
});
};
我想获取在此函数中发送项目的用户的电子邮件作为字符串变量。谁能建议我该怎么做?
item
有一个属性 creatorId
,它是发件人的用户 ID。 API getUserById
将 return 包含 emailAddress
属性的用户对象。
见 https://circuitsandbox.net/sdk/classes/Item.html#property_creatorId and https://circuitsandbox.net/sdk/classes/Client.html#method_getUserById 和 https://circuitsandbox.net/sdk/classes/User.html#property_emailAddress