|
2 | 2 |
|
3 | 3 | import com.workingdead.chatbot.scheduler.WendyScheduler; |
4 | 4 | import com.workingdead.chatbot.service.WendyService; |
| 5 | +import java.util.concurrent.CompletableFuture; |
| 6 | +import java.util.concurrent.TimeUnit; |
5 | 7 | import net.dv8tion.jda.api.entities.Member; |
6 | 8 | import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; |
7 | 9 | import net.dv8tion.jda.api.entities.emoji.Emoji; |
@@ -35,7 +37,18 @@ public WendyCommand(WendyService wendyService, WendyScheduler wendyScheduler) { |
35 | 37 | this.wendyService = wendyService; |
36 | 38 | this.wendyScheduler = wendyScheduler; |
37 | 39 | } |
38 | | - |
| 40 | + |
| 41 | + @Override |
| 42 | + public void onGuildJoin(net.dv8tion.jda.api.events.guild.GuildJoinEvent event) { |
| 43 | + TextChannel defaultChannel = event.getGuild().getDefaultChannel().asTextChannel(); |
| 44 | + if (defaultChannel != null) { |
| 45 | + defaultChannel.sendMessage(""" |
| 46 | + 안녕하세요! 일정 조율 도우미 웬디가 서버에 합류했어요 :D |
| 47 | + 일정을 조율하려면 채팅에 **'웬디 시작'** 이라고 입력해 주세요! |
| 48 | + """).queue(); |
| 49 | + } |
| 50 | + } |
| 51 | + |
39 | 52 | @Override |
40 | 53 | public void onMessageReceived(MessageReceivedEvent event) { |
41 | 54 | if (event.getAuthor().isBot()) return; |
@@ -176,7 +189,7 @@ private void handleStart(TextChannel channel) { |
176 | 189 |
|
177 | 190 | // 참석자 입력용 엔티티 셀렉트 메뉴 (유저 선택 드롭다운) |
178 | 191 | EntitySelectMenu attendeeMenu = EntitySelectMenu.create(ATTENDEE_SELECT_MENU_ID, EntitySelectMenu.SelectTarget.USER) |
179 | | - .setPlaceholder("참석자분들을 선택하거나 검색해서 골라주세요") |
| 192 | + .setPlaceholder("참석자를 선택 / 검색해 주세요.") |
180 | 193 | .setRequiredRange(1, 25) |
181 | 194 | .build(); |
182 | 195 |
|
@@ -219,6 +232,23 @@ private void handleDateInput(TextChannel channel, Member member, int weeks, bool |
219 | 232 |
|
220 | 233 | channel.sendMessage(voteUrl).queue(); |
221 | 234 | wendyScheduler.startSchedule(channel); |
| 235 | + |
| 236 | + |
| 237 | + // 투표 제한시간(24시간) + 30분 후 자동 종료 스케줄 |
| 238 | + CompletableFuture |
| 239 | + .delayedExecutor(3 * 60 + 30, TimeUnit.SECONDS) |
| 240 | + .execute(() -> { |
| 241 | + String chId = channel.getId(); |
| 242 | + // 스케줄러 정리 + 세션 종료 |
| 243 | + wendyScheduler.stopSchedule(chId); |
| 244 | + wendyService.endSession(chId); |
| 245 | + |
| 246 | + // 안내 메시지 전송 |
| 247 | + channel.sendMessage(""" |
| 248 | + 투표 제한 시간이 지나 웬디가 자동으로 종료되었어요 :D |
| 249 | + 다시 일정 조율이 필요하시면 '웬디 시작'을 입력해 주세요! |
| 250 | + """).queue(); |
| 251 | + }); |
222 | 252 | } |
223 | 253 |
|
224 | 254 | private void handleRevote(TextChannel channel) { |
|
0 commit comments