diff --git a/src/misskey/user.ts b/src/misskey/user.ts index 21c6be8..9338ef2 100644 --- a/src/misskey/user.ts +++ b/src/misskey/user.ts @@ -2,4 +2,6 @@ export type User = { id: string; name: string; username: string; + isFollowing: boolean; + isFollowed: boolean; }; diff --git a/src/modules/follow/index.ts b/src/modules/follow/index.ts new file mode 100644 index 0000000..2c4b061 --- /dev/null +++ b/src/modules/follow/index.ts @@ -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; + } + } +} diff --git a/src/serifs.ts b/src/serifs.ts index 55a52ba..9dc5665 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -260,6 +260,14 @@ export default { server: { cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...?' + }, + + follow: { + ok: 'フォローしました!', + + alreadyFollowed: 'えっ?既にあなたのことはフォローしていますよ!', + + ng: '嫌です...', } };