blob: 4edc9dde4b5e48285d9dbf847e4169d8d821dcd6 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
package com.juick.server.configuration;
import com.juick.server.TelegramBotManager;
import com.juick.server.XMPPBot;
import com.juick.server.component.LikeEvent;
import com.juick.server.component.MessageEvent;
import com.juick.server.component.SubscribeEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.inject.Inject;
@Configuration
public class EventsConfiguration {
@Inject
private TelegramBotManager telegramBotManager;
@Inject
private XMPPBot bot;
@Bean
ApplicationListener<MessageEvent> messageListener() {
return event -> {
telegramBotManager.processMessage(event.getMessage());
bot.processMessage(event.getMessage());
};
}
@Bean
ApplicationListener<LikeEvent> likeListener() {
return event -> {
telegramBotManager.processLike(event.getUser(), event.getMessage());
};
}
@Bean
ApplicationListener<SubscribeEvent> subscribeListener() {
return event -> {
telegramBotManager.processSubscribe(event.getUser(), event.getToUser());
};
}
}
|