Minayotan/src/modules/follow/index.ts

35 lines
700 B
TypeScript
Raw Normal View History

2019-01-14 16:14:22 +01:00
import autobind from 'autobind-decorator';
2020-09-19 03:40:44 +02:00
import Module from '@/module';
import Message from '@/message';
2019-01-23 12:10:58 +01:00
export default class extends Module {
public readonly name = 'follow';
2019-01-14 16:14:22 +01:00
@autobind
public install() {
return {
2019-01-15 04:01:58 +01:00
mentionHook: this.mentionHook
2019-01-14 16:14:22 +01:00
};
}
2019-01-14 16:14:22 +01:00
@autobind
2019-01-23 13:49:10 +01:00
private async mentionHook(msg: Message) {
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;
}
}
}