Implement Follow Back

This commit is contained in:
Xeltica 2018-12-02 23:20:29 +09:00
parent ce6bd6a7c3
commit 830d96a57a
3 changed files with 41 additions and 0 deletions

View file

@ -2,4 +2,6 @@ export type User = {
id: string;
name: string;
username: string;
isFollowing: boolean;
isFollowed: boolean;
};

View file

@ -0,0 +1,31 @@
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('フォロー')) {
if (msg.user.isFollowing) {
msg.reply(serifs.follow.alreadyFollowed);
} else if (msg.friend.love < -5) {
msg.reply(serifs.follow.ng);
} else {
this.ai.api("following/create", {
userId: msg.userId,
});
msg.reply(serifs.follow.ok);
}
return true;
} else {
return false;
}
}
}

View file

@ -260,6 +260,14 @@ export default {
server: {
cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...'
},
follow: {
ok: 'フォローしました!',
alreadyFollowed: 'えっ?既にあなたのことはフォローしていますよ!',
ng: '嫌です...',
}
};