38 lines
940 B
JavaScript
38 lines
940 B
JavaScript
|
/** 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
|