本文整理汇总了TypeScript中hubot.Brain类的典型用法代码示例。如果您正苦于以下问题:TypeScript Brain类的具体用法?TypeScript Brain怎么用?TypeScript Brain使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Brain类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
const loadState = (brain: Brain): SniperState => {
const state = brain.get<SniperState>('sniperino');
if (state) {
return state;
}
const newState = { games: {}, stats: {} };
brain.set('sniperino', newState);
return newState;
};
示例2:
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
示例3:
import * as Hubot from "hubot";
const robot = new Hubot.Robot<{}>(
'src/adapters',
'slack',
false,
'hubot',
);
robot; // $ExpectType Robot<{}>
robot.adapter; // $ExpectType {}
robot.hear(/hello/, () => null); // $ExpectType void
robot.on('test', () => null); // $ExpectType Robot<{}>
robot.emit('test', 'arg'); // $ExpectType boolean
const brain = new Hubot.Brain(robot);
brain; // $ExpectType Brain<{}>
brain.userForName('someone'); // $ExpectType User
brain.get('test'); // $ExpectType any
brain.set('test', 'test'); // $ExpectType Brain<{}>