Skip to content

Commit

Permalink
增加roll点功能
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyodi committed Oct 14, 2022
1 parent e03b306 commit e2def5e
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions src/main/java/com/badeling/msbot/serviceImpl/MsgServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,51 @@ private ReplyMsg handleNameMsg(ReceiveMsg receiveMsg) {
replyMsg.setAt_sender(true);
replyMsg.setAuto_escape(false);

//识图
if(raw_message.contains(MsbotConst.botName+"识图")) {
//识图
String[] result = mvpImageService.handImageMsg(receiveMsg);
raw_message = "";

//接受数据
try {
@SuppressWarnings("unchecked")
Map<String,Object> backMessage = (Map<String, Object>) JSONObject.parse(result[0]);
@SuppressWarnings("unchecked")
List<Map<String,String>> list = (List<Map<String, String>>) backMessage.get("words_result");
for(Map<String,String> a : list) {
raw_message = raw_message + a.get("words")+"\r\n";
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
replyMsg.setReply(raw_message);
return replyMsg;
}

//高精度识图
if(raw_message.contains(MsbotConst.botName+"高精度识图")){
//识图
String[] result = mvpImageService.handHigherImageMsg(receiveMsg);
//接受数据
raw_message = "高精度识图结果:\r\n";
try {
@SuppressWarnings("unchecked")
Map<String,Object> backMessage = (Map<String, Object>) JSONObject.parse(result[0]);
@SuppressWarnings("unchecked")
List<Map<String,String>> list = (List<Map<String, String>>) backMessage.get("words_result");
for(Map<String,String> a : list) {
raw_message = raw_message + a.get("words")+"\r\n";
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
replyMsg.setReply(raw_message);
return replyMsg;
}

//翻译
if(raw_message.contains(MsbotConst.botName+"翻译")) {
raw_message = raw_message.substring(raw_message.indexOf("翻译")+2);
Expand All @@ -793,6 +838,19 @@ private ReplyMsg handleNameMsg(ReceiveMsg receiveMsg) {
return null;
}

//roll点
if(raw_message.contains(MsbotConst.botName+"roll")){
try {
Random r = new Random();
int roll = r.nextInt(100)+1;
replyMsg.setReply("点数为:"+roll);
return replyMsg;
} catch (Exception e) {
replyMsg.setReply("出现了一个意料之外的错误");
e.printStackTrace();
return replyMsg;
}
}
//布尔学习
if(raw_message.contains("学习")&&raw_message.contains("布尔问")&&raw_message.contains("答")) {
if(receiveMsg.getUser_id().equalsIgnoreCase(MsbotConst.masterId)) {
Expand Down

0 comments on commit e2def5e

Please sign in to comment.