2018-12-03 08:48:00 +01:00
|
|
|
import 藍 from '../../ai';
|
|
|
|
import IModule from '../../module';
|
|
|
|
import MessageLike from '../../message-like';
|
|
|
|
|
|
|
|
export default class FollowModule implements IModule {
|
|
|
|
public readonly name = 'follow';
|
|
|
|
private ai: 藍;
|
|
|
|
|
2018-12-03 09:12:47 +01:00
|
|
|
public install = (ai: 藍) => {
|
2018-12-03 08:48:00 +01:00
|
|
|
this.ai = ai;
|
|
|
|
}
|
|
|
|
|
|
|
|
public onMention = (msg: MessageLike) => {
|
2018-12-03 09:12:47 +01:00
|
|
|
if (msg.text && msg.includes(['フォロー', 'フォロバ', 'follow me'])) {
|
|
|
|
if (!msg.user.isFollowing) {
|
|
|
|
this.ai.api('following/create', {
|
2018-12-03 08:48:00 +01:00
|
|
|
userId: msg.userId,
|
|
|
|
});
|
2018-12-03 09:12:47 +01:00
|
|
|
return {
|
2018-12-03 09:20:15 +01:00
|
|
|
reaction: msg.friend.love >= 0 ? 'like' : null
|
2018-12-03 09:12:47 +01:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
return {
|
2018-12-03 09:20:15 +01:00
|
|
|
reaction: msg.friend.love >= 0 ? 'hmm' : null
|
2018-12-03 09:12:47 +01:00
|
|
|
};
|
|
|
|
}
|
2018-12-03 08:48:00 +01:00
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|