Add some comments

This commit is contained in:
syuilo 2019-01-16 02:48:14 +09:00
parent 09fc4291f0
commit eef0e78d7e
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -49,6 +49,11 @@ export default class 藍 {
public friends: loki.Collection<FriendDoc>;
/**
*
* @param account 使
* @param modules
*/
constructor(account: User, modules: Module[]) {
this.account = account;
this.modules = modules;
@ -128,6 +133,10 @@ export default class 藍 {
this.log(chalk.green.bold('Ai am now running!'));
}
/**
*
* ()
*/
@autobind
private async onReceiveMessage(msg: Message): Promise<void> {
this.log(chalk.gray(`<<< An message received: ${chalk.underline(msg.id)}`));
@ -151,6 +160,9 @@ export default class 藍 {
let reaction = 'love';
//#region
// コンテキストがあればコンテキストフック呼び出し
// なければそれぞれのモジュールについてフックが引っかかるまで呼び出し
if (context != null) {
const handler = this.contextHooks[context.module];
const res = handler(msg, context.data);
@ -170,6 +182,7 @@ export default class 藍 {
reaction = res.reaction;
}
}
//#endregion
await delay(1000);
@ -189,12 +202,18 @@ export default class 藍 {
}
}
/**
* 稿
*/
@autobind
public async post(param: any) {
const res = await this.api('notes/create', param);
return res.createdNote;
}
/**
*
*/
@autobind
public sendMessage(userId: any, param: any) {
return this.api('messaging/messages/create', Object.assign({
@ -202,6 +221,9 @@ export default class 藍 {
}, param));
}
/**
* APIを呼び出します
*/
@autobind
public api(endpoint: string, param?: any) {
return request.post(`${config.apiUrl}/${endpoint}`, {
@ -211,6 +233,14 @@ export default class 藍 {
});
};
/**
*
* @param module 待ち受けるモジュール名
* @param key
* @param isDm
* @param id ID稿ID
* @param data
*/
@autobind
public subscribeReply(module: Module, key: string, isDm: boolean, id: string, data?: any) {
this.contexts.insertOne(isDm ? {
@ -228,6 +258,11 @@ export default class 藍 {
});
}
/**
*
* @param module 解除するモジュール名
* @param key
*/
@autobind
public unsubscribeReply(module: Module, key: string) {
this.contexts.findAndRemove({