|
45 | 45 | import java.util.function.Function; |
46 | 46 | import java.util.function.Supplier; |
47 | 47 |
|
| 48 | +import static java.util.concurrent.TimeUnit.HOURS; |
48 | 49 | import static vc.util.DiscordMarkdownEscape.escape; |
49 | 50 |
|
50 | 51 | @Component |
@@ -215,6 +216,23 @@ private void processChatsKeywordQueue() { |
215 | 216 | } |
216 | 217 | } |
217 | 218 |
|
| 219 | + @Scheduled(initialDelay = 1, fixedRate = 1, timeUnit = HOURS) |
| 220 | + private void refreshTopicListeners() { |
| 221 | + if (!watchesEnabled) return; |
| 222 | + try { |
| 223 | + LOGGER.info("Refreshing watch topic listeners"); |
| 224 | + connectionsTopic.removeListener(connectionsTopicId); |
| 225 | + connectionsTopicId = connectionsTopic.addListener(String.class, (channel, msg) -> connectionsTopicListener(msg)); |
| 226 | + chatsTopic.removeListener(chatsTopicId); |
| 227 | + chatsTopicId = chatsTopic.addListener(String.class, (channel, msg) -> chatsTopicListener(msg)); |
| 228 | + deathsTopic.removeListener(deathsTopicId); |
| 229 | + deathsTopicId = deathsTopic.addListener(String.class, (channel, msg) -> deathsTopicListener(msg)); |
| 230 | + LOGGER.info("Watch topic listeners refreshed"); |
| 231 | + } catch (Exception e) { |
| 232 | + LOGGER.error("Failed to refresh watch topic listeners", e); |
| 233 | + } |
| 234 | + } |
| 235 | + |
218 | 236 | private <T> void processQueue( |
219 | 237 | String id, |
220 | 238 | ConcurrentLinkedDeque<T> queue, |
|
0 commit comments