mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
Merge branch 'develop' of github.com:chatopera/cosin into develop
This commit is contained in:
commit
3aab65d639
5
contact-center/163.source.list
Normal file
5
contact-center/163.source.list
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
deb http://mirrors.163.com/ubuntu/ xenial main restricted universe multiverse
|
||||||
|
deb http://mirrors.163.com/ubuntu/ xenial-security main restricted universe multiverse
|
||||||
|
deb http://mirrors.163.com/ubuntu/ xenial-updates main restricted universe multiverse
|
||||||
|
deb http://mirrors.163.com/ubuntu/ xenial-proposed main restricted universe multiverse
|
||||||
|
deb http://mirrors.163.com/ubuntu/ xenial-backports main restricted universe multiverse
|
@ -6,6 +6,8 @@ ARG VCS_REF
|
|||||||
LABEL org.label-schema.vcs-ref=$VCS_REF \
|
LABEL org.label-schema.vcs-ref=$VCS_REF \
|
||||||
org.label-schema.vcs-url="https://github.com/chatopera/cosin"
|
org.label-schema.vcs-url="https://github.com/chatopera/cosin"
|
||||||
|
|
||||||
|
COPY 163.source.list /etc/apt/sources.list
|
||||||
|
|
||||||
# Set timezone
|
# Set timezone
|
||||||
RUN apt-get update && \
|
RUN apt-get update && \
|
||||||
apt-get install --no-install-recommends -y tzdata && \
|
apt-get install --no-install-recommends -y tzdata && \
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.chatopera.cc.app.handler.api.rest;
|
package com.chatopera.cc.app.handler.api.rest;
|
||||||
|
|
||||||
import com.chatopera.bot.exception.ChatbotException;
|
import com.chatopera.bot.exception.ChatbotException;
|
||||||
|
import com.chatopera.cc.app.basic.MainContext;
|
||||||
import com.chatopera.cc.app.basic.MainUtils;
|
import com.chatopera.cc.app.basic.MainUtils;
|
||||||
import com.chatopera.cc.app.handler.Handler;
|
import com.chatopera.cc.app.handler.Handler;
|
||||||
import com.chatopera.cc.app.handler.api.request.RestUtils;
|
import com.chatopera.cc.app.handler.api.request.RestUtils;
|
||||||
@ -79,6 +80,8 @@ public class ApiChatbotController extends Handler {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ConsultInviteRepository consultInviteRes;
|
private ConsultInviteRepository consultInviteRes;
|
||||||
|
|
||||||
|
private String botBaseUrl;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST)
|
@RequestMapping(method = RequestMethod.POST)
|
||||||
@Menu(type = "apps", subtype = "chatbot", access = true)
|
@Menu(type = "apps", subtype = "chatbot", access = true)
|
||||||
@ApiOperation("聊天机器人")
|
@ApiOperation("聊天机器人")
|
||||||
@ -277,14 +280,16 @@ public class ApiChatbotController extends Handler {
|
|||||||
invite.setAiname(c.getName());
|
invite.setAiname(c.getName());
|
||||||
} else {
|
} else {
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_6);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:该机器人不存在,请先创建机器人, 登录 https://bot.chatopera.com");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。提示:该机器人不存在,请先创建机器人, 登录 https://bot.chatopera.com");
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
} catch (ChatbotException e) {
|
} catch (ChatbotException e) {
|
||||||
|
logger.error("bot create error", e);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。");
|
||||||
return resp;
|
return resp;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
logger.error("bot request error", e);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_7);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_7);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "更新智能问答引擎失败。" + e.toString());
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "更新智能问答引擎失败。" + e.toString());
|
||||||
return resp;
|
return resp;
|
||||||
@ -423,7 +428,7 @@ public class ApiChatbotController extends Handler {
|
|||||||
*/
|
*/
|
||||||
private JsonObject create(JsonObject j, String creater, String organ, String orgi) {
|
private JsonObject create(JsonObject j, String creater, String organ, String orgi) {
|
||||||
JsonObject resp = new JsonObject();
|
JsonObject resp = new JsonObject();
|
||||||
String baseUrl = "https://bot.chatopera.com";
|
String baseUrl = getBotBaseUrl();
|
||||||
String snsid = null;
|
String snsid = null;
|
||||||
String workmode = null;
|
String workmode = null;
|
||||||
String clientId = null;
|
String clientId = null;
|
||||||
@ -480,7 +485,7 @@ public class ApiChatbotController extends Handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret);
|
com.chatopera.bot.sdk.Chatbot bot = new com.chatopera.bot.sdk.Chatbot(clientId, secret, getBotBaseUrl());
|
||||||
|
|
||||||
if (bot.exists()) { // 该机器人存在,clientId 和 Secret配对成功
|
if (bot.exists()) { // 该机器人存在,clientId 和 Secret配对成功
|
||||||
// 创建成功
|
// 创建成功
|
||||||
@ -532,14 +537,22 @@ public class ApiChatbotController extends Handler {
|
|||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
} catch (ChatbotException e) {
|
} catch (ChatbotException e) {
|
||||||
|
logger.error("bot create error", e);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_5);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:无法访问该机器人,请确认【1】该服务器可以访问互联网,【2】该聊天机器人已经创建,【3】clientId和Secret正确设置。");
|
||||||
return resp;
|
return resp;
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
|
logger.error("bot request error", e);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
resp.addProperty(RestUtils.RESP_KEY_RC, RestUtils.RESP_RC_FAIL_4);
|
||||||
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:不合法的聊天机器人服务URL。");
|
resp.addProperty(RestUtils.RESP_KEY_ERROR, "Chatopera开发者平台提示:不合法的聊天机器人服务URL。");
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getBotBaseUrl(){
|
||||||
|
if(this.botBaseUrl == null)
|
||||||
|
this.botBaseUrl = MainContext.getContext().getEnvironment().getProperty("chatopera.bot.url");
|
||||||
|
return this.botBaseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@
|
|||||||
socket.on('message', function(data) {
|
socket.on('message', function(data) {
|
||||||
var chat=document.getElementsByClassName('chatting-left').innerText;
|
var chat=document.getElementsByClassName('chatting-left').innerText;
|
||||||
chat = data.message;
|
chat = data.message;
|
||||||
// console.log("On Server Message from Chatbot: ", chat, ", 动态参数:", data.expmsg);
|
console.log("On Server Message from Chatbot: ", chat, ", 动态参数 data.expmsg:", data.expmsg);
|
||||||
|
|
||||||
if(data.messageType == "image"){
|
if(data.messageType == "image"){
|
||||||
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
chat = "<a href='"+data.message+"&original=true' target='_blank'><img src='"+data.message+"' class='ukefu-media-image'/></a>" ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user