提交 ed3b0f86 编写于 作者: 小傅哥's avatar 小傅哥

小傅哥,feat:新增silenced参数配置

上级 ef3f5a23
......@@ -65,9 +65,10 @@ public class TaskRegistrarAutoConfig implements EnvironmentAware, SchedulingConf
String openAiKey = taskGroup.get("openAiKey").toString();
String cronExpressionBase64 = taskGroup.get("cronExpression").toString();
String cronExpression = new String(Base64.getDecoder().decode(cronExpressionBase64), StandardCharsets.UTF_8);
boolean silenced = Boolean.parseBoolean(taskGroup.get("silenced").toString());
logger.info("创建任务 groupName:{} groupId:{} cronExpression:{}", groupName, groupId, cronExpression);
// 添加任务
taskRegistrar.addCronTask(new ChatbotTask(groupName, groupId, cookie, openAiKey, zsxqApi, openAI), cronExpression);
taskRegistrar.addCronTask(new ChatbotTask(groupName, groupId, cookie, openAiKey, zsxqApi, openAI, silenced), cronExpression);
}
}
......
......@@ -27,17 +27,19 @@ public class ChatbotTask implements Runnable {
private String groupId;
private String cookie;
private String openAiKey;
private boolean silenced;
private IZsxqApi zsxqApi;
private IOpenAI openAI;
public ChatbotTask(String groupName, String groupId, String cookie, String openAiKey, IZsxqApi zsxqApi, IOpenAI openAI) {
public ChatbotTask(String groupName, String groupId, String cookie, String openAiKey, IZsxqApi zsxqApi, IOpenAI openAI, boolean silenced) {
this.groupName = groupName;
this.groupId = groupId;
this.cookie = cookie;
this.openAiKey = openAiKey;
this.zsxqApi = zsxqApi;
this.openAI = openAI;
this.silenced = silenced;
}
@Override
......@@ -68,7 +70,7 @@ public class ChatbotTask implements Runnable {
Topics topic = topics.get(topics.size() - 1);
String answer = openAI.doChatGPT(openAiKey, topic.getQuestion().getText().trim());
// 3. 问题回复
boolean status = zsxqApi.answer(groupId, cookie, topic.getTopic_id(), answer, false);
boolean status = zsxqApi.answer(groupId, cookie, topic.getTopic_id(), answer, silenced);
logger.info("{} 编号:{} 问题:{} 回答:{} 状态:{}", groupName, topic.getTopic_id(), topic.getQuestion().getText(), answer, status);
} catch (Exception e) {
logger.error("{} 自动回答问题异常", groupName, e);
......
......@@ -10,9 +10,11 @@ chatbot-api:
cookie: # 知识星球个人cookie信息
openAiKey: # 自行申请 https://beta.openai.com/overview 或者联系小傅哥 fustack 付费申请【购买虚拟号码等需要支付】。
cronExpression: 0/30 * * * * ? # 执行的频次配置,参考:cron.qqe2.com
silenced: false
group02:
groupName: 码农会锁
groupId: 28885518425541 # 知识星球ID
cookie: # 知识星球个人cookie信息
openAiKey: # 自行申请 https://beta.openai.com/overview 或者联系小傅哥 fustack 付费申请【购买虚拟号码等需要支付】。
cronExpression: 0/30 * * * * ? # 执行的频次配置,参考:cron.qqe2.com
\ No newline at end of file
cronExpression: 0/30 * * * * ? # 执行的频次配置,参考:cron.qqe2.com
silenced: true
\ No newline at end of file
......@@ -33,9 +33,9 @@ public class ApiTest {
public void query_unanswered_questions() throws IOException {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpGet get = new HttpGet("https://api.zsxq.com/v2/groups/28885518425541/topics?scope=unanswered_questions&count=20");
HttpGet get = new HttpGet("https://api.zsxq.com/v2/groups/48411118851818/topics?scope=unanswered_questions&count=20");
get.addHeader("cookie", "");
get.addHeader("cookie", "知识星球个人cookie信息");
get.addHeader("Content-Type", "application/json;charset=utf8");
CloseableHttpResponse response = httpClient.execute(get);
......@@ -52,7 +52,7 @@ public class ApiTest {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("https://api.zsxq.com/v2/topics/412884248251548/answer");
post.addHeader("cookie", "__cuid=5330a556392a4c5b8084b4cbc165e0f3; amp_fef1e8=930aec23-e22e-4f11-8864-0389bd5095d1R...1g55hl79m.1g55hl79t.1.1.2; UM_distinctid=183e61195d535b-0bddac94679c75-19525635-1aeaa0-183e61195d7c52; sensorsdata2015jssdkcross={\"distinct_id\":\"241858242255511\",\"first_id\":\"17ebd0b4317ecb-0b27f672c2d3af-133a6253-1296000-17ebd0b4318ba7\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"17ebd0b4317ecb-0b27f672c2d3af-133a6253-1296000-17ebd0b4318ba7\",\"identities\":\"eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMTgwMmQ2YjZiOWIxZjMtMGQ4YzMzZjhmYTA3YmEtMzU3MzZhMDMtMTI5NjAwMC0xODAyZDZiNmI5YzEwODYiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIyNDE4NTgyNDIyNTU1MTEifQ==\",\"history_login_id\":{\"name\":\"$identity_login_id\",\"value\":\"241858242255511\"}}; abtest_env=product; zsxqsessionid=8fae9a083a4874ab833c2158a44deb82; zsxq_access_token=5D862869-1229-A9B6-1BC1-C662EC4B16DD_D625BA7FD9CBBDFA");
post.addHeader("cookie", "知识星球个人cookie信息");
post.addHeader("Content-Type", "application/json;charset=utf8");
String paramJson = "{\n" +
......@@ -81,7 +81,7 @@ public class ApiTest {
HttpPost post = new HttpPost("https://api.openai.com/v1/completions");
post.addHeader("Content-Type", "application/json");
post.addHeader("Authorization", "Bearer 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");
post.addHeader("Authorization", "Bearer 自行申请 https://beta.openai.com/overview");
String paramJson = "{\"model\": \"text-davinci-003\", \"prompt\": \"帮我写一个java冒泡排序\", \"temperature\": 0, \"max_tokens\": 1024}";
......
docs/images/docker配置.png

255.7 KB | W: | H:

docs/images/docker配置.png

180.9 KB | W: | H:

docs/images/docker配置.png
docs/images/docker配置.png
docs/images/docker配置.png
docs/images/docker配置.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册