This repository has been archived on 2024-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
line-bot-js/MemberJoinedClass.js

38 lines
940 B
JavaScript
Raw Permalink Normal View History

2023-01-10 04:01:05 +00:00
/** MemberJoined */
class MemberJoinedClass {
constructor(bot, LineNotify) {
this.bot = bot;
this.LineNotify = LineNotify;
}
MemberJoined(event) {
switch (event.source.groupId) {
case process.env.toBadminton: {
this.Badminton_MemberJoin(event)
break;
}
default:
break;
}
}
async Badminton_MemberJoin(event) {
const members = event.joined.members;
for (let i = 0; i < members.length; i++) {
const userId = members[i].userId;
this.SendBadminton_Welcome(event, event.source.groupId, userId)
}
}
async SendBadminton_Welcome(event, groupId, userId) {
const userdata = await this.bot.getGroupMemberProfile(groupId, userId);
if (userdata && userdata.displayName) {
const message = `歡迎尊貴的 ${userdata.displayName} 降臨羽球團`;
event.reply(message);
this.LineNotify.SendBadmintonNotify();
}
}
}
module.exports = MemberJoinedClass