ai/src/modules/follow/index.ts

35 lines
788 B
TypeScript

import from '../../ai';
import IModule from '../../module';
import MessageLike from '../../message-like';
import serifs from '../../serifs';
export default class FollowModule implements IModule {
public readonly name = 'follow';
private ai: ;
public install = (ai: ) => {
this.ai = ai;
}
public onMention = (msg: MessageLike) => {
if (msg.text && msg.text.includes('フォロー')) {
let user: any;
this.ai.api("users/show", {
userId: msg.userId,
}).then(u => {
user = u;
if (user.isFollowing) {
msg.reply(serifs.follow.alreadyFollowed);
} else {
this.ai.api("following/create", {
userId: msg.userId,
});
msg.reply(serifs.follow.ok);
}
});
return true;
} else {
return false;
}
}
}