From 990cd7ccd272795b5f64deeeacaa037e531375a0 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 3 Dec 2018 17:12:47 +0900 Subject: [PATCH] :v: --- src/index.ts | 2 +- src/misskey/user.ts | 1 + src/modules/follow/index.ts | 28 ++++++++++++---------------- src/serifs.ts | 10 ---------- 4 files changed, 14 insertions(+), 27 deletions(-) diff --git a/src/index.ts b/src/index.ts index 966c5c3..3de339f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,10 +12,10 @@ import WelcomeModule from './modules/welcome'; import TimerModule from './modules/timer'; import DiceModule from './modules/dice'; import ServerModule from './modules/server'; +import FollowModule from './modules/follow'; import * as request from 'request-promise-native'; import IModule from './module'; -import FollowModule from './modules/follow'; const promiseRetry = require('promise-retry'); console.log('--- starting ai... ---'); diff --git a/src/misskey/user.ts b/src/misskey/user.ts index 21c6be8..d2438cc 100644 --- a/src/misskey/user.ts +++ b/src/misskey/user.ts @@ -2,4 +2,5 @@ export type User = { id: string; name: string; username: string; + isFollowing: boolean; }; diff --git a/src/modules/follow/index.ts b/src/modules/follow/index.ts index ad501bf..0a01e63 100644 --- a/src/modules/follow/index.ts +++ b/src/modules/follow/index.ts @@ -1,33 +1,29 @@ 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: 藍) => { + public install = (ai: 藍) => { this.ai = ai; } public onMention = (msg: MessageLike) => { - if (msg.text && msg.text.includes('フォロー')) { - let user: any; - this.ai.api("users/show", { + if (msg.text && msg.includes(['フォロー', 'フォロバ', 'follow me'])) { + if (!msg.user.isFollowing) { + this.ai.api('following/create', { 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; + return { + reaction: 'like' + }; + } else { + return { + reaction: 'hmm' + }; + } } else { return false; } diff --git a/src/serifs.ts b/src/serifs.ts index bb6e336..10501fb 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -261,16 +261,6 @@ export default { server: { cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...?' }, - - follow: { - ok: 'フォローしました!', - - requireMoreLove: 'もう少し仲良くなったらお願いできますか?', - - alreadyFollowed: 'えっ?既にあなたのことはフォローしていますよ!', - - ng: '嫌です...', - } }; export function getSerif(serif: string | string[]): string {