-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTelegramBot.java
33 lines (29 loc) · 1.15 KB
/
TelegramBot.java
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
import org.apache.camel.builder.RouteBuilder;
public class TelegramBot extends RouteBuilder {
/*
kamel run --property camel.component.telegram.authorization-token=$TOKEN TelegramBot.java
*/
@Override
public void configure() throws Exception {
from("telegram:bots")
.choice()
.when()
.simple("${in.body} != null")
.to("direct:response1");
from("direct:response1")
.log("Incoming message from Telegram is ${in.body}")
// .setBody()
// .simple("You said ${in.body}?")
// .to("telegram:bots");
.choice()
.when(simple("${bodyAs(java.lang.String)} contains \"#camelkrocks\""))
.setBody(simple("Did somebody say #camelkrocks? Of course it does!"))
// .to("telegram:bots")
// adding this else that echoes
.otherwise()
.setBody(simple("You said ${in.body} ?"))
// .to("telegram:bots")
.end()
.to("telegram:bots") ;
}
}