1
This commit is contained in:
@@ -237,7 +237,7 @@ jarvis:
|
|||||||
# wait_reply 时服务端会等多条 Bot 回复,宜适当加大
|
# wait_reply 时服务端会等多条 Bot 回复,宜适当加大
|
||||||
read-timeout-ms: 120000
|
read-timeout-ms: 120000
|
||||||
wait-reply: true
|
wait-reply: true
|
||||||
reply-take-nth: 2
|
# reply_take_nth 由 Java 按 bot 固定:开(AJL05_bot)=2,慢开(QingBao)=3
|
||||||
# Ollama 大模型服务(监控健康度调试用)
|
# Ollama 大模型服务(监控健康度调试用)
|
||||||
ollama:
|
ollama:
|
||||||
base-url: http://192.168.8.34:11434
|
base-url: http://192.168.8.34:11434
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ jarvis:
|
|||||||
connect-timeout-ms: 8000
|
connect-timeout-ms: 8000
|
||||||
read-timeout-ms: 120000
|
read-timeout-ms: 120000
|
||||||
wait-reply: true
|
wait-reply: true
|
||||||
reply-take-nth: 2
|
# reply_take_nth:Java 按 bot 固定(开=2,慢开=3)
|
||||||
# Ollama 大模型服务(监控健康度调试用)
|
# Ollama 大模型服务(监控健康度调试用)
|
||||||
ollama:
|
ollama:
|
||||||
base-url: http://192.168.8.34:11434
|
base-url: http://192.168.8.34:11434
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.util.regex.Pattern;
|
|||||||
* 企微「开」/「慢开」+ 手机号:POST 局域网 /v1/forward,body 含 {@code text}(手机号)与 {@code bot},
|
* 企微「开」/「慢开」+ 手机号:POST 局域网 /v1/forward,body 含 {@code text}(手机号)与 {@code bot},
|
||||||
* 将 JSON 中的 {@code reply_text} 作为回显。
|
* 将 JSON 中的 {@code reply_text} 作为回显。
|
||||||
* <p>
|
* <p>
|
||||||
* 可配置 {@code wait_reply} / {@code reply_take_nth}:服务端先发 text,再等 Bot 回 N 次,
|
* {@code wait_reply} 时按 Bot 取第 N 条回复:{@code AJL05_bot} 为第 2 条,{@code QingBaoJuXWsgkbot} 为第 3 条;
|
||||||
* 将第 N 条内容填入 {@code reply_text}(前几条如「查询中…」由对端丢弃)。
|
* 「慢开」返回正文会去掉固定广告行(替换为空格)。
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@@ -38,6 +38,20 @@ public class OpenPhoneForwardService {
|
|||||||
/** 「慢开」→ 对应 Bot 用户名 */
|
/** 「慢开」→ 对应 Bot 用户名 */
|
||||||
private static final String BOT_SLOW_OPEN = "QingBaoJuXWsgkbot";
|
private static final String BOT_SLOW_OPEN = "QingBaoJuXWsgkbot";
|
||||||
|
|
||||||
|
private static final int REPLY_TAKE_NTH_OPEN_BOT = 2;
|
||||||
|
|
||||||
|
private static final int REPLY_TAKE_NTH_SLOW_BOT = 3;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* QingBao 机器人回复尾部的固定推广行(👉 与正文间可能含 ZWJ U+200D),整段替换为空格。
|
||||||
|
*/
|
||||||
|
private static final String[] QINGBAO_REPLY_JUNK = {
|
||||||
|
"\uD83D\uDC49\u200D公安路线查询价格表 (https://t.me/+C20ADPmEKJU0ZGFl)\uD83D\uDC48",
|
||||||
|
"\uD83D\uDC49\u200D如机器人提示被注销点我防丢 (https://telegra.ph/qingbaoju-10-01)\uD83D\uDC48",
|
||||||
|
"\uD83D\uDC49公安路线查询价格表 (https://t.me/+C20ADPmEKJU0ZGFl)\uD83D\uDC48",
|
||||||
|
"\uD83D\uDC49如机器人提示被注销点我防丢 (https://telegra.ph/qingbaoju-10-01)\uD83D\uDC48",
|
||||||
|
};
|
||||||
|
|
||||||
@Value("${jarvis.phone-forward.enabled:false}")
|
@Value("${jarvis.phone-forward.enabled:false}")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
|
|
||||||
@@ -57,10 +71,6 @@ public class OpenPhoneForwardService {
|
|||||||
@Value("${jarvis.phone-forward.wait-reply:true}")
|
@Value("${jarvis.phone-forward.wait-reply:true}")
|
||||||
private boolean waitReply;
|
private boolean waitReply;
|
||||||
|
|
||||||
/** 与 wait_reply 配合:取第几条 Bot 回复作为 reply_text,须 ≥ 1 */
|
|
||||||
@Value("${jarvis.phone-forward.reply-take-nth:2}")
|
|
||||||
private int replyTakeNth;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return 非 null 表示本条消息已由本服务处理(含错误提示);null 表示不匹配规则
|
* @return 非 null 表示本条消息已由本服务处理(含错误提示);null 表示不匹配规则
|
||||||
*/
|
*/
|
||||||
@@ -111,10 +121,7 @@ public class OpenPhoneForwardService {
|
|||||||
body.put("text", phone);
|
body.put("text", phone);
|
||||||
body.put("bot", bot);
|
body.put("bot", bot);
|
||||||
if (waitReply) {
|
if (waitReply) {
|
||||||
int nth = replyTakeNth >= 1 ? replyTakeNth : 1;
|
int nth = replyTakeNthForBot(bot);
|
||||||
if (replyTakeNth < 1) {
|
|
||||||
log.warn("phone-forward reply-take-nth={} 无效,已按 1 处理", replyTakeNth);
|
|
||||||
}
|
|
||||||
body.put("wait_reply", true);
|
body.put("wait_reply", true);
|
||||||
body.put("reply_take_nth", nth);
|
body.put("reply_take_nth", nth);
|
||||||
}
|
}
|
||||||
@@ -147,6 +154,9 @@ public class OpenPhoneForwardService {
|
|||||||
if (!StringUtils.hasText(reply)) {
|
if (!StringUtils.hasText(reply)) {
|
||||||
return "「转发服务」未返回 reply_text。";
|
return "「转发服务」未返回 reply_text。";
|
||||||
}
|
}
|
||||||
|
if (BOT_SLOW_OPEN.equals(bot)) {
|
||||||
|
reply = filterQingBaoAdLines(reply);
|
||||||
|
}
|
||||||
return reply;
|
return reply;
|
||||||
} finally {
|
} finally {
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
@@ -159,6 +169,22 @@ public class OpenPhoneForwardService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int replyTakeNthForBot(String bot) {
|
||||||
|
if (BOT_SLOW_OPEN.equals(bot)) {
|
||||||
|
return REPLY_TAKE_NTH_SLOW_BOT;
|
||||||
|
}
|
||||||
|
return REPLY_TAKE_NTH_OPEN_BOT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将固定广告段替换为空格后 trim。 */
|
||||||
|
private static String filterQingBaoAdLines(String reply) {
|
||||||
|
String s = reply;
|
||||||
|
for (String junk : QINGBAO_REPLY_JUNK) {
|
||||||
|
s = s.replace(junk, " ");
|
||||||
|
}
|
||||||
|
return s.trim();
|
||||||
|
}
|
||||||
|
|
||||||
private static String readAll(InputStream is) throws java.io.IOException {
|
private static String readAll(InputStream is) throws java.io.IOException {
|
||||||
if (is == null) {
|
if (is == null) {
|
||||||
return "";
|
return "";
|
||||||
|
|||||||
Reference in New Issue
Block a user