[ 
https://issues.apache.org/jira/browse/CAMEL-12955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16708845#comment-16708845
 ] 

ASF GitHub Bot commented on CAMEL-12955:
----------------------------------------

dmvolod commented on a change in pull request #2653: CAMEL-12955 Create a 
Camel-ChatScript component changes
URL: https://github.com/apache/camel/pull/2653#discussion_r238698024
 
 

 ##########
 File path: 
components/camel-chatscript/src/main/java/org/apache/camel/component/chatscript/ChatScriptEndpoint.java
 ##########
 @@ -0,0 +1,145 @@
+/**
+ * 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.chatscript;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Represents a ChatScript endpoint.
+ */
+@UriEndpoint(firstVersion = "2.24.0", scheme = "chatscript", title = 
"ChatScript", syntax = "chatscript:hostname:port/botname",  producerOnly = 
true, label = "ai,chatscript")
+public class ChatScriptEndpoint extends DefaultEndpoint {
+
+    public static final int DEFAULT_PORT = 1024;
+
+    private static final String URI_ERROR = "Invalid URI. Format must be of 
the form chatscript://hostname[:port]/botname?[options...]";
+    @UriPath (description = "Hostname or IP of the server on which CS server 
is running") 
+    @Metadata(required = "true")
+    private String hostname;
+    @UriPath(description = "Port on which ChatScript is listening to", 
defaultValue = "" + DEFAULT_PORT)
+    private int port;
+    @UriPath(description = "Name of the Bot in CS to converse with")
+    @Metadata(required = "true")
+    private String botname;
+    @UriParam(description = "Username who initializes the CS conversation. To 
be set when chat is initialized from camel route", label = "username")
+    private String chatusername;
+    @UriParam (description = "Issues :reset command to start a new 
conversation everytime", label = "reset", defaultValue = "false")
+    private boolean resetchat;
+    private ChatScriptBot bot;
+
+    public ChatScriptEndpoint(String endpointUri) {
+        super(endpointUri);
+    }
+    public ChatScriptEndpoint() {
+    }
+
+    public ChatScriptEndpoint(String uri, String remaining,
+            ChatScriptComponent component) throws URISyntaxException {
+        super(uri, component);
+
+        URI remainingUri = new URI("tcp://" + remaining);
+        port = remainingUri.getPort() == -1 ? DEFAULT_PORT : 
remainingUri.getPort();
+        if (ObjectHelper.isEmpty(remainingUri.getPath())) {
+            throw new IllegalArgumentException(URI_ERROR);
+        }
+        hostname = remainingUri.getHost();
+       if (ObjectHelper.isEmpty(hostname)) { 
+            throw new IllegalArgumentException(URI_ERROR);
+        }
+        botname = remainingUri.getPath();
+        if (ObjectHelper.isEmpty(botname)) {
+            throw new IllegalArgumentException(URI_ERROR);
+        }
+        botname = botname.substring(1);
+        setbot(new ChatScriptBot(getHostName(), getPort(), getBotName(), ""));
+
+    }
+    public boolean isResetChat() {
+        return resetchat;
+    }
+
+    public void setResetchat(boolean resetChat) {
+        this.resetchat = resetChat;
+    }
+
+    public String getChatUserName() {
+        return chatusername;
+    }
+
+    public void setChatUserName(String chatusername) {
+        this.chatusername = chatusername;
+    }
+
+    public Producer createProducer() throws Exception {
+        return new ChatScriptProducer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("Chatscript consumer not 
supported");
 
 Review comment:
   'ChatScript' instead of 'Chatscript'

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Create a Camel-ChatScript component
> -----------------------------------
>
>                 Key: CAMEL-12955
>                 URL: https://issues.apache.org/jira/browse/CAMEL-12955
>             Project: Camel
>          Issue Type: New Feature
>            Reporter: Varun Krish
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: Future
>
>
> Create new component to interact with ChatScript BOTs.
> Chat Script: [https://github.com/bwilcox-1234/ChatScript]
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to