我有一个懒惰的机器人,可以回复发送给用户的消息。 我做这样的事情:
startSlackRtm() {
this.slackObject = slackbot({
require_delivery: true
});
this.slackObject.log("Going to start the slack rtm connection. ");
const slackBot = this.slackObject.spawn({
retry: true,
token: this.botConstants.token
});
slackBot.startRTM((err, bot, payload) => {
if(err) {
this.slackObject.log('error', "RTM connection failed. I will retry in a few seconds. ");
return setTimeout(this.startSlackRtm(), 9000);
}
this.slackObject.log("Slack is running fine now. ");
})
}
reply(bot, username, reply) {
bot.reply({
channel: username
}, reply)
}
slackHears() {
this.slackObject.hears(['.*'], ['direct_message', 'mention'], (bot, message) => {
let userId = message.user, userProfile = {};
bot.api.users.info({
token: this.botConstants.token,
user: userId
}, async(err, res) => {
if (err) this.slackObject.log("error", err);
userProfile = res.user.profile;
let username = userProfile.email.split("@")[0];
this.reply(bot, this.botConstants.defaultChannel, feedbackDetail);
})
})
}
但是我有一个用例,我只想基于一些kafka事件发送通知,或者只是说我想向用户@tom发送消息,而无需他与我的机器人进行交互。
我该怎么做..任何帮助将不胜感激。 如果您需要更多信息,请告诉我。