mirror of
https://github.com/syuilo/ai.git
synced 2025-03-25 21:12:56 +00:00
Implement Follow Back
This commit is contained in:
parent
ce6bd6a7c3
commit
830d96a57a
3 changed files with 41 additions and 0 deletions
|
@ -2,4 +2,6 @@ export type User = {
|
|||
id: string;
|
||||
name: string;
|
||||
username: string;
|
||||
isFollowing: boolean;
|
||||
isFollowed: boolean;
|
||||
};
|
||||
|
|
31
src/modules/follow/index.ts
Normal file
31
src/modules/follow/index.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -260,6 +260,14 @@ export default {
|
|||
|
||||
server: {
|
||||
cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...?'
|
||||
},
|
||||
|
||||
follow: {
|
||||
ok: 'フォローしました!',
|
||||
|
||||
alreadyFollowed: 'えっ?既にあなたのことはフォローしていますよ!',
|
||||
|
||||
ng: '嫌です...',
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue