@@ -64,7 +64,8 @@ public final class HelpSystemHelper {
64
64
65
65
private static final ScheduledExecutorService SERVICE = Executors .newScheduledThreadPool (3 );
66
66
private static final int SEND_UNCATEGORIZED_ADVICE_AFTER_MINUTES = 5 ;
67
-
67
+ private static final int SEND_NO_ACTIVITY_ADVICE_AFTER_MINUTES = 5 ;
68
+ public static final int MAX_MESSAGES_TO_LOOK_BACK = 10 ;
68
69
private final Predicate <String > isOverviewChannelName ;
69
70
private final String overviewChannelPattern ;
70
71
private final Predicate <String > isStagingChannelName ;
@@ -333,6 +334,61 @@ private void executeUncategorizedAdviceCheck(long threadChannelId, long authorId
333
334
}).queue ();
334
335
}
335
336
337
+ void scheduleNoActivityAdviceCheck (long threadChannelId , long authorId ) {
338
+ SERVICE .schedule (() -> {
339
+ try {
340
+ executeNoActivityAdviceCheck (threadChannelId , authorId );
341
+ } catch (Exception e ) {
342
+ logger .warn (
343
+ "Unknown error during a no activity advice check on thread {} by author {}." ,
344
+ threadChannelId , authorId , e );
345
+ }
346
+ }, SEND_NO_ACTIVITY_ADVICE_AFTER_MINUTES , TimeUnit .MINUTES );
347
+ }
348
+
349
+ private void executeNoActivityAdviceCheck (long threadChannelId , long authorId ) {
350
+ logger .debug ("Executing no activity advice check for thread {} by author {}." ,
351
+ threadChannelId , authorId );
352
+
353
+ ThreadChannel threadChannel = jda .getThreadChannelById (threadChannelId );
354
+ if (threadChannel == null ) {
355
+ logger .debug (
356
+ "Channel for no activity advice check seems to be deleted (thread {} by author {})." ,
357
+ threadChannelId , authorId );
358
+ return ;
359
+ }
360
+
361
+ if (threadChannel .isArchived ()) {
362
+ logger .debug (
363
+ "Channel for no activity advice check is archived already (thread {} by author {})." ,
364
+ threadChannelId , authorId );
365
+ return ;
366
+ }
367
+ if (hasNoAuthorActivity (authorId , threadChannel )) {
368
+ MessageEmbed embed = HelpSystemHelper .embedWith (
369
+ """
370
+ Hey there %s👋 It has been a bit after you created this thread and you still did not share any details of your question.
371
+ Helpers have seen your question already and are just waiting for you to elaborate on your problem and provide detailed information on it 👌
372
+ """
373
+ .formatted (User .fromId (authorId ).getAsMention ()));
374
+ threadChannel .sendMessageEmbeds (embed ).queue ();
375
+ }
376
+ }
377
+
378
+ private static boolean hasNoAuthorActivity (long authorId , ThreadChannel threadChannel ) {
379
+ int messagesFromOthers = 0 ;
380
+ for (Message message : threadChannel .getIterableHistory ()) {
381
+ if (messagesFromOthers == MAX_MESSAGES_TO_LOOK_BACK ) {
382
+ return false ;
383
+ }
384
+ if (message .getAuthor ().getIdLong () == authorId ) {
385
+ return false ;
386
+ }
387
+ messagesFromOthers ++;
388
+ }
389
+ return true ;
390
+ }
391
+
336
392
record HelpThreadName (@ Nullable ThreadActivity activity , @ Nullable String category ,
337
393
String title ) {
338
394
static HelpThreadName ofChannelName (CharSequence channelName ) {
0 commit comments