This commit is contained in:
syuilo 2018-12-03 17:12:47 +09:00
parent 5c3408714b
commit 990cd7ccd2
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
4 changed files with 14 additions and 27 deletions

View file

@ -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... ---');

View file

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

View file

@ -1,7 +1,6 @@
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';
@ -12,22 +11,19 @@ export default class FollowModule implements IModule {
}
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);
});
return {
reaction: 'like'
};
} else {
this.ai.api("following/create", {
userId: msg.userId,
});
msg.reply(serifs.follow.ok);
return {
reaction: 'hmm'
};
}
});
return true;
} else {
return false;
}

View file

@ -261,16 +261,6 @@ export default {
server: {
cpu: 'サーバーの負荷が高そうです。大丈夫でしょうか...'
},
follow: {
ok: 'フォローしました!',
requireMoreLove: 'もう少し仲良くなったらお願いできますか?',
alreadyFollowed: 'えっ?既にあなたのことはフォローしていますよ!',
ng: '嫌です...',
}
};
export function getSerif(serif: string | string[]): string {