# 群机器人+邮箱中间件
**Repository Path**: wb04307201/chatbot-spring-boot-starter
## Basic Information
- **Project Name**: 群机器人+邮箱中间件
- **Description**: 一个消息群发中间件,
只需要简单的配置和编码,即可将相同的消息发送到钉钉、飞书、企业微信聊天群以及邮箱,
统一消息维护方式,发送时会按照对应的平台类型自动进行转换
- **Primary Language**: Java
- **License**: Apache-2.0
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 5
- **Forks**: 0
- **Created**: 2022-11-11
- **Last Updated**: 2025-03-14
## Categories & Tags
**Categories**: Uncategorized
**Tags**: 钉钉, 飞书, 企业微信, 邮箱, 消息推送
## README
# chatbot-spring-boot-starter
该项目已暂停更新,新项目增加钉钉、飞书、企业微信对单独用户的信息发送,请查看[消息中间件](https://gitee.com/wb04307201/message-spring-boot-starter)
[](https://jitpack.io/#com.gitee.wb04307201/chatbot-spring-boot-starter)
> 一个消息群发中间件
> 只需要简单的配置和编码,即可将相同的消息发送到钉钉、飞书、企业微信聊天群以及邮箱
> 统一消息维护方式,发送时会按照对应的平台类型自动进行转换
- [钉钉](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
| | SubLine.title | 标题 | 标题 | text |
| | SubLine.bold | 加粗 | 加粗 | text | | ## 其他1:内置界面 发送的消息可通过http://ip:端口/chat/robot/list进行查看 注意:如配置了context-path需要在地址中对应添加  ## 其他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 Listlist(ChatbotHistory chatbotHistory) { try { Connection conn = connectionPool.getConnection(); String sql = ModelSqlUtils.selectSql(HISTORY, new ChatbotHistory()); List 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() + "%'"); if (!condition.isEmpty()) sql = sql + " where " + String.join("and", condition); List res = ExecuteSqlUtils.executeQuery(conn, sql, new HashMap<>(), ChatbotHistory.class); connectionPool.returnConnection(conn); return res; } catch (SQLException | InterruptedException e) { throw new RuntimeException(e); } } @Override public void init() { try { Connection conn = connectionPool.getConnection(); if (!ExecuteSqlUtils.isTableExists(conn, HISTORY, connectionPool.getDbType())) { ExecuteSqlUtils.executeUpdate(conn, ModelSqlUtils.createSql(HISTORY, new ChatbotHistory()), new HashMap<>()); } } catch (SQLException | InterruptedException e) { throw new RuntimeException(e); } } } ``` 并添加配置指向类 ```yaml chatbot: config: chatbot-record: cn.wubo.chatbot.demo.H2ChatbotRecordImpl ```