7 Commits

Author SHA1 Message Date
mol
05e936a067 Merge branch 'main' of git.liliyamol.cn:mol/mol-robot
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2023-12-25 10:59:30 +08:00
mol
5c93d3a30f fix: error effect app run 2023-12-25 10:58:47 +08:00
mol
61e81a1174 1.2.2 2023-12-25 10:55:07 +08:00
mol
f8840f9024 更新 README.md
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: mol <hiiragi10073@163.com>
2023-12-14 08:21:16 +00:00
mol
ba596d4f06 remove user limit
All checks were successful
continuous-integration/drone/push Build is passing
2023-12-14 15:35:53 +08:00
mol
baba5dc342 1.2.1 2023-12-14 15:34:52 +08:00
mol
ba119d85c9 test
Some checks are pending
continuous-integration/drone/push Build is running
2023-12-14 15:33:41 +08:00
6 changed files with 101 additions and 14 deletions

View File

@ -1,3 +1,88 @@
### 模儿bot
### 模儿bot
友链:[mirai-js](https://drincann.github.io/Mirai-js/#/v2.x/Bot?id=on)
模儿bot是一个提供与mirai-api-http交互的webhook服务器并提供一些小工具的bot。
#### 功能
1. webhook服务器
> http请求方式, method="post", enctype="application/json", path=/
请求示例
```
{
"event": "sendForwardMessage",
"subs": {
"groups": [],
"users": []
},
"from": "新闻",
"messages": [
{
"message": "PlayStation Plus二档会员十二月阵容给他爱5、FF起源等",
"imgUrls": [
"http://img2.a9vg.com/i/a9-article-list_x256/cms3.0/2023/1214/20231214104321-2309-33362.jpg"
],
"originUrl": "http://www.a9vg.com/article/215182"
}
],
"body": "Hello World",
}
```
请求参数说明
发送转发消息请求
|参数|类型|说明|是否必填|可选项|
|--|--|--|--|--|
|event|string|发送消息的类型|是|`sendForwardMessage`|
|subs|object|指定接收消息的群或者人|是|--|
|from|string|转发消息时,指定发送人的名称|否|--|
|messages|message[]|转发的消息列表|是|--|
发送一般消息请求
|参数|类型|说明|是否必填|可选项|
|--|--|--|--|--|
|event|string|发送消息的类型|是|`sendMessage2`|
|subs|object|指定接收消息的群或者人|是|--|
|from|string|转发消息时,指定发送人的名称|否|--|
|messages|string[]|转发的消息列表|是|--|
|imgUrls|string[]|图片地址|否|--|
|originUrl|string|源地址|否|--|
|at|number|需要at的qq号|否|--|
2. 聊天指令
1. 厨娘
- 随机菜肴推荐 #模儿晚上吃什么)
#### 安装运行
1. 直接运行
```shell
npm i -g node@18.17.0
npm i
touch .env
# 修改 .env 文件
vim .env
node app.js
```
2. docker 运行(开发中)
#### 环境配置
```
MIRAI_HTTP_API_HOST=<mirai-api-http地址>
MIRAI_HTTP_API_VERIFY_KEY=<mirai-api-http密钥>
WEB_HOOK_PORT=<webhook服务器端口>
QQ=<机器人qq号>
DEFAULT_SUB_GROUPS=<默认订阅群(暂时无用)>
DEFAULT_SUB_USERS=<默认订阅人 (暂时无用)>
IMG_NUMBER_IN_ONE_MESSAGE=<单个消息允许的配图数量>
COOK_SUB_GROUPS=<订阅厨娘的群>
MASTER=<管理员qq号>
```
#### 友链
- [mirai-js](https://drincann.github.io/Mirai-js/#/v2.x/Bot?id=on)
- [今天我们来做菜](https://github.com/YunYouJun/cook)

2
app.js
View File

@ -53,4 +53,6 @@ let retryCount = 0;
webhook.startListen(port);
logger(`开始监听端口: ${port}`);
bot.sendMessageToFriend(+process.env.MASTER, '模儿bot已就绪');
})(process.env.WEB_HOOK_PORT);

View File

@ -20,23 +20,23 @@ export default class CreateBot {
});
}
async sendMessageToFriend(qq, message) {
sendMessageToFriend(qq, message) {
logger(`发送好友[${qq}]消息进入消息队列`);
return this.queue
.addMethod(this.bot.sendMessage.bind(this.bot, { friend: qq, message }))
.then(
(res) => {
logger(`发送好友[${qq}]消息成功 ${res}`);
return res;
return ['success', res];
},
(e) => {
logger.warning(`发送好友[${qq}]消息失败,错误信息${e}`);
return Promise.reject(e);
return ['failed', e];
},
);
}
async sendMessageToGroup(groupId, message) {
sendMessageToGroup(groupId, message) {
logger(`发送群[${groupId}]消息进入消息队列`);
return this.queue
.addMethod(
@ -45,11 +45,11 @@ export default class CreateBot {
.then(
(res) => {
logger(`发送群[${groupId}]消息成功 ${res}`);
return res;
return ['success', res];
},
(e) => {
logger.warning(`发送群[${groupId}]消息失败,错误信息${e}`);
return Promise.reject(e);
return ['failed', e];
},
);
}

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "mirai-middle-server",
"version": "1.2.0",
"version": "1.2.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "mirai-middle-server",
"version": "1.2.0",
"version": "1.2.2",
"dependencies": {
"dayjs": "^1.11.7",
"mirai-js": "^2.8.11",

View File

@ -1,6 +1,6 @@
{
"name": "mirai-middle-server",
"version": "1.2.0",
"version": "1.2.2",
"description": "使用miraijs开发,用于连接kuginn等外部服务与mirai通信的中转服务器",
"author": "mol",
"main": "app.js",
@ -20,4 +20,4 @@
"devDependencies": {
"dotenv": "^16.1.1"
}
}
}

View File

@ -41,9 +41,9 @@ function cookInit() {
Bot.bot.on(
'FriendMessage',
new Middleware().friendFilter(cookSubs.users).textProcessor().done(dealCommon),
new Middleware().textProcessor().done(dealCommon),
);
Bot.sendMessageToFriend(752753679, '测试');
Bot.sendMessageToFriend(+process.env.MASTER, '厨娘系统 启动!');
logger('cook 初始化完成')
}