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 TimerModule from './modules/timer';
import DiceModule from './modules/dice'; import DiceModule from './modules/dice';
import ServerModule from './modules/server'; import ServerModule from './modules/server';
import FollowModule from './modules/follow';
import * as request from 'request-promise-native'; import * as request from 'request-promise-native';
import IModule from './module'; import IModule from './module';
import FollowModule from './modules/follow';
const promiseRetry = require('promise-retry'); const promiseRetry = require('promise-retry');
console.log('--- starting ai... ---'); console.log('--- starting ai... ---');

View file

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

View file

@ -1,7 +1,6 @@
import from '../../ai'; import from '../../ai';
import IModule from '../../module'; import IModule from '../../module';
import MessageLike from '../../message-like'; import MessageLike from '../../message-like';
import serifs from '../../serifs';
export default class FollowModule implements IModule { export default class FollowModule implements IModule {
public readonly name = 'follow'; public readonly name = 'follow';
@ -12,22 +11,19 @@ export default class FollowModule implements IModule {
} }
public onMention = (msg: MessageLike) => { public onMention = (msg: MessageLike) => {
if (msg.text && msg.text.includes('フォロー')) { if (msg.text && msg.includes(['フォロー', 'フォロバ', 'follow me'])) {
let user: any; if (!msg.user.isFollowing) {
this.ai.api("users/show", { this.ai.api('following/create', {
userId: msg.userId, userId: msg.userId,
}).then(u => { });
user = u; return {
if (user.isFollowing) { reaction: 'like'
msg.reply(serifs.follow.alreadyFollowed); };
} else { } else {
this.ai.api("following/create", { return {
userId: msg.userId, reaction: 'hmm'
}); };
msg.reply(serifs.follow.ok);
} }
});
return true;
} else { } else {
return false; return false;
} }

View file

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