Minayotan/src/modules/follow/index.ts

32 lines
697 B
TypeScript
Raw Normal View History

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: ) => {
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', {
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
};
}
} else {
return false;
}
}
}