You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/05/09 08:51:05 UTC
[camel] 06/06: License header and updated documentation
This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
commit 372412829c23ec7552cf99eea903cd59283e0a71
Author: Willian Antunes <wi...@gmail.com>
AuthorDate: Sun May 6 07:15:05 2018 -0700
License header and updated documentation
---
.../src/main/docs/telegram-component.adoc | 57 ++++++++++++++++++++++
.../telegram/model/InlineKeyboardButton.java | 16 ++++++
.../telegram/model/ReplyKeyboardMarkup.java | 16 ++++++
3 files changed, 89 insertions(+)
diff --git a/components/camel-telegram/src/main/docs/telegram-component.adoc b/components/camel-telegram/src/main/docs/telegram-component.adoc
index b90f06c..3ce6891 100644
--- a/components/camel-telegram/src/main/docs/telegram-component.adoc
+++ b/components/camel-telegram/src/main/docs/telegram-component.adoc
@@ -310,3 +310,60 @@ to("telegram:bots/123456789:AAE_dLq5C19xwGjw3yiC2NvEUrZcejK21-Q987654321:AAE_dLq
---------------------------------------------------------
Note that the corresponding URI parameter is simply `chatId`.
+
+### Customizing keyboard
+
+You can customize the user keyboard instead of asking him to write an option. `OutgoingTextMessage` has the property `ReplyKeyboardMarkup` which can be used for such thing.
+
+[source,java]
+---------------------------------------------------------
+from("telegram:bots/123456789:AAE_dLq5C19xwGjw3yiC2NvEUrZcejK21-Q987654321:AAE_dLq5C19xwOmg5yiC2NvSrkT3wj5Q1-L")
+ .process(exchange -> {
+
+ OutgoingTextMessage msg = new OutgoingTextMessage();
+ msg.setText("Choose one option!");
+
+ InlineKeyboardButton buttonOptionOneI = InlineKeyboardButton.builder()
+ .text("Option One - I").build();
+
+ InlineKeyboardButton buttonOptionOneII = InlineKeyboardButton.builder()
+ .text("Option One - II").build();
+
+ InlineKeyboardButton buttonOptionTwoI = InlineKeyboardButton.builder()
+ .text("Option Two - I").build();
+
+ ReplyKeyboardMarkup replyMarkup = ReplyKeyboardMarkup.builder()
+ .keyboard()
+ .addRow(Arrays.asList(buttonOptionOneI, buttonOptionOneII))
+ .addRow(Arrays.asList(buttonOptionTwoI))
+ .close()
+ .oneTimeKeyboard(true)
+ .build();
+
+ msg.setReplyKeyboardMarkup(replyMarkup);
+
+ exchange.getIn().setBody(msg);
+ })
+ .to("telegram:bots/123456789:AAE_dLq5C19xwGjw3yiC2NvEUrZcejK21-Q987654321:AAE_dLq5C19xwOmg5yiC2NvSrkT3wj5Q1-L");
+---------------------------------------------------------
+
+If you want to disable it the next message must have the property `removeKeyboard` set on `ReplyKeyboardMarkup` object.
+
+[source,java]
+---------------------------------------------------------
+from("telegram:bots/123456789:AAE_dLq5C19xwGjw3yiC2NvEUrZcejK21-Q987654321:AAE_dLq5C19xwOmg5yiC2NvSrkT3wj5Q1-L")
+ .process(exchange -> {
+
+ OutgoingTextMessage msg = new OutgoingTextMessage();
+ msg.setText("Your answer was accepted!");
+
+ ReplyKeyboardMarkup replyMarkup = ReplyKeyboardMarkup.builder()
+ .removeKeyboard(true)
+ .build();
+
+ msg.setReplyKeyboardMarkup(replyMarkup);
+
+ exchange.getIn().setBody(msg);
+ })
+ .to("telegram:bots/123456789:AAE_dLq5C19xwGjw3yiC2NvEUrZcejK21-Q987654321:AAE_dLq5C19xwOmg5yiC2NvSrkT3wj5Q1-L");
+---------------------------------------------------------
\ No newline at end of file
diff --git a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/InlineKeyboardButton.java b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/InlineKeyboardButton.java
index 06fdaa0..f3f2b4f 100644
--- a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/InlineKeyboardButton.java
+++ b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/InlineKeyboardButton.java
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.telegram.model;
public class InlineKeyboardButton {
diff --git a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/ReplyKeyboardMarkup.java b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/ReplyKeyboardMarkup.java
index d2894cc..db66984 100644
--- a/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/ReplyKeyboardMarkup.java
+++ b/components/camel-telegram/src/main/java/org/apache/camel/component/telegram/model/ReplyKeyboardMarkup.java
@@ -1,3 +1,19 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.telegram.model;
import java.io.Serializable;
--
To stop receiving notification emails like this one, please contact
acosentino@apache.org.