本文整理匯總了TypeScript中hubot.Robot.hear方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Robot.hear方法的具體用法?TypeScript Robot.hear怎麽用?TypeScript Robot.hear使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hubot.Robot
的用法示例。
在下文中一共展示了Robot.hear方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: resetHype
export = (robot: Robot) => {
robot.hear(/hype/i, res => {
resetHype();
if (total < maxHype) {
total += Math.min(hypeIncrement, maxHype - total);
res.send(`${gettingHyped} : ${total}%`);
} else {
res.send(`${overHyped}`);
}
});
};
示例2:
export = (robot: Robot) => {
robot.hear(/\bmei\b/i, res => {
res.send(`Mei is${res.random(is)} bae.`);
});
};
示例3:
export = (robot: Robot) => robot.hear(/told/i, res => {
res.send(`${unchecked} Not told\n${checked} ${res.random(tolds)}`);
});
示例4:
import * as Hubot from "hubot";
const brain = new Hubot.Brain();
brain; // $ExpectType Brain
brain.userForName('someone'); // $ExpectType any
const robot = new Hubot.Robot(
'src/adapters',
'slack',
false,
'hubot',
);
robot; // $ExpectType Robot
robot.hear(/hello/, () => null); // $ExpectType void
示例5:
module.exports = (robot: Robot<any>) => {
robot.hear(/hello/i, (res: Response) => {
res.reply("world")
})
}