本文整理匯總了TypeScript中hubot-slack.Robot.respond方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Robot.respond方法的具體用法?TypeScript Robot.respond怎麽用?TypeScript Robot.respond使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hubot-slack.Robot
的用法示例。
在下文中一共展示了Robot.respond方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: default
export default (robot: Robot) => {
robot.respond(/who am i/i, (response) => {
const user = response.envelope.user
if (user) {
const msg = JSON.stringify(user, null, 2)
robot.send({ id: response.envelope.user.id }, {
attachments: [{
fallback: `\`\`\`${msg}\`\`\``,
color: 'good',
text: `\`\`\`${msg}\`\`\``,
mrkdwn_in: ['text'],
}],
})
} else {
robot.send({ id: response.envelope.user.id }, `Could not find that user`)
}
})
robot.respond(/who is (.+)/i, (response) => {
const dataStore = robot.adapter.client.rtm.dataStore
const userId = response.envelope.user.id
if (!dataStore.getUserById(userId).is_admin) {
return response.reply('Only admins can use the `who is` command')
}
const userName = response.match[1]
const user = dataStore.getUserByName(userName)
if (user) {
const msg = JSON.stringify(user, null, 2)
robot.send({ id: response.envelope.user.id }, {
attachments: [{
fallback: `\`\`\`${msg}\`\`\``,
color: 'good',
text: `\`\`\`${msg}\`\`\``,
mrkdwn_in: ['text'],
}],
})
} else {
robot.send({ id: response.envelope.user.id }, `Could not find that user`)
}
})
}