# chatbot-spring-boot-starter
该项目已暂停更新,新项目增加钉钉、飞书、企业微信对单独用户的信息发送,请查看[消息中间件](https://gitee.com/wb04307201/message-spring-boot-starter)
[![](https://jitpack.io/v/com.gitee..svg)](https://jitpack.io/#com.gitee.)
> 一个消息群发中间件
> 只需要简单的配置和编码,即可将相同的消息发送到钉钉、飞书、企业微信聊天群以及邮箱
> 统一消息维护方式,发送时会按照对应的平台类型自动进行转换
- [钉钉](https://open.dingtalk.com/document/group/custom-robot-access)
- [企业微信](https://developer.work.weixin.qq.com/document/path/91770)
- [飞书](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN)
> 钉钉和飞书需要使用加签,配置时需要维护secret
> 目前支持两种消息模式 **文本** 和 **markdown(飞书对应为富文本,邮箱对应为html)**
## [代码示例](https://gitee.com/wb04307201/chatbot-demo)
## 第一步 增加 JitPack 仓库
```xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
```
## 第二步 引入jar
```xml
<dependency>
<groupId>com.gitee.wb04307201</groupId>
<artifactId>chatbot-spring-boot-starter</artifactId>
<version>1.1.2</version>
</dependency>
```
## 第三步 在启动类上加上`@EnableChatbot`注解
```java
@EnableChatbot
@SpringBootApplication
public class ChatbotDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringTestApplication.class, args);
}
}
```
## 第四步 `application.yml`配置文件中添加以下相关配置,可以配置多个群
```yaml
chatbot:
config:
chatbot-info:
- alias: dd-1
chatbot-type: dingtalk
# webhook地址 https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxx
token: 为webhook地址中xxxxxxxxxxxxxxxxx部分
secret: secret
- alias: wx-1
chatbot-type: weixin
# webhook地址 https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxxxxxxxxxxxx
token: 为webhook地址中xxxxxxxxxxxxxxxxx部分
- alias: fs-1
chatbot-type: feishu
# webhook地址 https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxx
token: 为webhook地址中xxxxxxxxxxxxxxxxx部分
secret: secret
- alias: mail-1
chatbot-type: mail
from: 发件邮箱
to: 收件邮箱1,收件邮箱2
host: stmp地址
username: 用户名
password: 密码
```
## 第五步 注入IChatbotService并调用发送信息
```java
@RestController
public class DemoController {
@Autowired
ChatbotService chatbotService;
@GetMapping(value = "/chat/robot/test")
public String send() {
//发送到全部平台
/*return chatbotService.send(
RequestContent.buildMarkdown()
.title("测试群发")
.addLine(SubLine.title("这是一行标题1",1))
.addLine(SubLine.title("这是一行标题2",2))
.addLine(SubLine.text("这是一行文本"))
.addLine(SubLine.link("这是一行链接","https://gitee.com/"))
.addLine(SubLine.quote("这是一行引用"))
.addLine(SubLine.bold("这是一行加粗"))
.atAll(true)
).toString();*/
//发送到某类平台
/*return chatbotService.send(
RequestContent.buildMarkdown()
.addChatbotType(ChatbotType.DINGTALK)
.title("测试群发")
.addLine(SubLine.title("这是一行标题1",1))
.addLine(SubLine.title("这是一行标题2",2))
.addLine(SubLine.text("这是一行文本"))
.addLine(SubLine.link("这是一行链接","https://gitee.com/"))
.addLine(SubLine.quote("这是一行引用"))
.addLine(SubLine.bold("这是一行加粗"))
.atAll(true)
).toString();*/
//发送到某几个平台
return chatbotService.send(
RequestContent.buildMarkdown().addAlias("dd-1", "mail-1")
.title("测试群发")
.addLine(SubLine.title("这是一行标题1", 1))
.addLine(SubLine.title("这是一行标题2", 2))
.addLine(SubLine.text("这是一行文本"))
.addLine(SubLine.link("这是一行链接", "https://gitee.com/"))
.addLine(SubLine.quote("这是一行引用"))
.addLine(SubLine.bold("这是一行加粗"))
.atAll(true)
).toString();
}
}
```
目前支持的类型与转换格式对照如下表
| chatbot | 钉钉 | 微信 | 飞书 | 邮件 |
|---------------|-----|------|------|--------------|
| SubLine.text | 文字 | 文字 | text | <p> |
| SubLine.title | 标题 | 标题 | text | <h1>~<h6> |
| SubLine.link | 链接 | 链接 | a | <a> |
| SubLine.quote | 引用 | 引用文字 | text | <blockquote> |
| SubLine.bold | 加粗 | 加粗 | text | <strong> |
## 其他1:内置界面
发送的消息可通过http://ip:端口/chat/robot/list进行查看
注意:如配置了context-path需要在地址中对应添加
![img.png](img.png)
## 其他2:动态增减平台信息
```java
//可以通过如下方法添加平台信息
chatbotService.addDingtalk
chatbotService.addFeishu
chatbotService.addWeixin
chatbotService.addMail
//可以通过如下方法删除平台信息
chatbotService.removeByAlias
```
## 其他3:实际使用中,可通过配置和实现日志接口方法将数据持久化到数据库中
继承IChatbotRecord并实现方法,例如
```java
@Component
public class H2ChatbotRecordImpl implements IChatbotRecord {
private static final String HISTORY = "chat_robot_history";
private static ConnectionPool connectionPool = new ConnectionPool(new ConnectionParam());
@Override
public ChatbotHistory save(ChatbotHistory chatbotHistory) {
try {
Connection conn = connectionPool.getConnection();
if (!StringUtils.hasLength(chatbotHistory.getId())) {
chatbotHistory.setId(UUID.randomUUID().toString());
ExecuteSqlUtils.executeUpdate(conn, ModelSqlUtils.insertSql(HISTORY, chatbotHistory), new HashMap<>());
} else {
ExecuteSqlUtils.executeUpdate(conn, ModelSqlUtils.updateByIdSql(HISTORY, chatbotHistory), new HashMap<>());
}
connectionPool.returnConnection(conn);
} catch (SQLException | InterruptedException e) {
throw new RuntimeException(e);
}
return chatbotHistory;
}
@Override
public List<ChatbotHistory> list(ChatbotHistory chatbotHistory) {
try {
Connection conn = connectionPool.getConnection();
String sql = ModelSqlUtils.selectSql(HISTORY, new ChatbotHistory());
List<String> condition = new ArrayList<>();
if (StringUtils.hasLength(chatbotHistory.getType()))
condition.add(" type = '" + chatbotHistory.getType() + "'");
if (StringUtils.hasLength(chatbotHistory.getAlias()))
condition.add(" alias like '%" + chatbotHistory.getAlias() + "%'");
if (StringUtils.hasLength(chatbotHistory.getRequest()))
condition.add(" request like '%" + chatbotHistory.getRequest() + "%'");
if (StringUtils.hasLength(chatbotHistory.getResponse()))
condition.add(" response like '%" + chatbotHistory.getResponse() + "%'");
没有合适的资源?快使用搜索试试~ 我知道了~
基于Java的钉钉、飞书、企业微信聊天群以及邮箱消息统一维护中间件源码.zip
共78个文件
java:28个
map:22个
css:16个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 139 浏览量
2024-02-21
20:26:33
上传
评论
收藏 1.42MB ZIP 举报
温馨提示
钉钉、飞书、企业微信聊天群以及邮箱消息统一维护中间件源码.zip 一个消息群发中间件 只需要简单的配置和编码,即可将相同的消息发送到钉钉、飞书、企业微信聊天群以及邮箱 统一消息维护方式,发送时会按照对应的平台类型自动进行转换
资源推荐
资源详情
资源评论
收起资源包目录
一个消息群发中间件, 只需要简单的配置和编码,即可将相同的消息发送到钉钉、飞书、企业微信聊天群以及邮箱, 统一消息维护方式,发送时.zip (78个子文件)
chatbot-spring-boot-starter-master
pom.xml 4KB
src
main
resources
template
list.ftl 3KB
META-INF
resources
bootstrap
5.1.3
js
bootstrap.js 145KB
bootstrap.bundle.js.map 418KB
bootstrap.esm.min.js.map 218KB
bootstrap.bundle.min.js.map 323KB
bootstrap.min.js 58KB
bootstrap.esm.js 136KB
bootstrap.bundle.min.js 76KB
bootstrap.bundle.js 205KB
bootstrap.js.map 284KB
bootstrap.esm.js.map 283KB
bootstrap.min.js.map 215KB
bootstrap.esm.min.js 71KB
css
bootstrap-grid.css.map 197KB
bootstrap.min.css 160KB
bootstrap-reboot.rtl.min.css.map 47KB
bootstrap.rtl.min.css.map 648KB
bootstrap-utilities.rtl.min.css 52KB
bootstrap-grid.css 71KB
bootstrap-utilities.rtl.css 70KB
bootstrap-grid.min.css.map 119KB
bootstrap-reboot.rtl.css.map 107KB
bootstrap-reboot.min.css.map 39KB
bootstrap-utilities.css 70KB
bootstrap-utilities.css.map 188KB
bootstrap-reboot.rtl.css 7KB
bootstrap.rtl.min.css 160KB
bootstrap.css.map 525KB
bootstrap.css 201KB
bootstrap-utilities.rtl.min.css.map 109KB
bootstrap-grid.rtl.min.css.map 120KB
bootstrap-utilities.rtl.css.map 188KB
bootstrap.rtl.css.map 525KB
bootstrap-reboot.css 7KB
bootstrap-reboot.rtl.min.css 6KB
bootstrap-utilities.min.css.map 109KB
bootstrap-utilities.min.css 52KB
bootstrap-reboot.css.map 107KB
bootstrap-grid.rtl.css.map 197KB
bootstrap-grid.rtl.css 71KB
bootstrap-grid.rtl.min.css 52KB
bootstrap-grid.min.css 52KB
bootstrap.min.css.map 441KB
bootstrap-reboot.min.css 6KB
bootstrap.rtl.css 200KB
java
cn
wubo
chatbot
message
SubLine.java 820B
SubBoldLine.java 201B
TextContent.java 673B
SubLinkLine.java 301B
SubTextLine.java 201B
SubTitleLine.java 308B
SubQuoteLine.java 204B
MarkdownContent.java 915B
RequestContent.java 560B
SubLineEnum.java 114B
record
ChatbotHistory.java 276B
impl
MemChatbotRecordImpl.java 2KB
IChatbotRecord.java 488B
EnableChatbot.java 348B
platform
ISendService.java 712B
feishu
FeishuServiceImpl.java 6KB
dingtalk
DingtalkServiceImpl.java 6KB
mail
MailServiceImpl.java 5KB
wx
WeixinServiceImpl.java 4KB
core
ChatbotService.java 3KB
ChatbotInfo.java 334B
ChatbotType.java 646B
exception
DingtalkRuntimeException.java 296B
FeishuRuntimeException.java 291B
ChatbotRuntimeException.java 294B
page
ChatbotListServlet.java 3KB
config
ChatbotConfigurationProperties.java 481B
ChatbotConfiguration.java 4KB
LICENSE 11KB
.gitignore 17B
img.png 62KB
README.md 9KB
共 78 条
- 1
资源评论
武昌库里写JAVA
- 粉丝: 3244
- 资源: 1925
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于pytorch+Unet进行MRI肝脏图像分割源码+数据集+模型.zip
- 在Android Studio中开发一个Android App项目步骤
- 基于yolov8实现进行物体跟踪源码.zip
- Java多线程学习Java多线程学习Java多线程学习Java多线程学习.txt
- 算法数据结构-动态规划算法(Dynamic Programming)超详细总结加应用案例讲解.txt
- 2024最强秋招八股文(精简、纯手打)2024最强秋招八股文(精简、纯手打).txt
- 基于tensorflow多特征融合的微表情识别python源码.zip
- 基于yolov8实现人脸检测的python源码+运行说明.zip
- Micron Memory DDR3 SDRAM 全系列AD集成库(原理图库+PCB封装库).IntLib
- 基于tensorflow多特征融合的微表情识别python源码+详细使用说明.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功