kokkoro-plugin-kfc 1.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -21
- package/README.md +10 -17
- package/lib/index.js +12 -25
- package/package.json +22 -29
- package/src/index.ts +21 -0
- package/tsconfig.json +13 -0
- package/lib/service.js +0 -48
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c)
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020-2023 Yuki
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
1
|
# kokkoro-plugin-kfc
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
vivo 50
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Install:**
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
|
-
# 切换至 bot 目录
|
|
9
|
-
cd bot
|
|
10
|
-
|
|
11
|
-
# 安装 npm 包
|
|
12
8
|
npm i kokkoro-plugin-kfc
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## 环境变量
|
|
11
|
+
**Usage:**
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
```javascript
|
|
14
|
+
import { mountPlugin } from '@kokkoro/core';
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
# KFC 时间
|
|
23
|
-
KFC_DATE=0 0 12 * * 4
|
|
16
|
+
await mountPlugin('kokkoro-plugin-kfc');
|
|
24
17
|
```
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## 鸣谢
|
|
19
|
+
**Command:**
|
|
29
20
|
|
|
30
|
-
|
|
21
|
+
格式:`/疯狂星期四`
|
|
22
|
+
场景:群聊 & 频道
|
|
23
|
+
功能:随机输出肯德基疯狂星期四段子
|
package/lib/index.js
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
plugin
|
|
14
|
-
.version(pkg.version)
|
|
15
|
-
.schedule(process.env.KFC_DATE ?? '0 0 12 * * 4', async () => {
|
|
16
|
-
await service.autoSend();
|
|
17
|
-
});
|
|
18
|
-
plugin
|
|
19
|
-
.command('say')
|
|
20
|
-
.description('v50 看看实力')
|
|
21
|
-
.sugar(/(v|V|vivo|Vivo|v我|V我)50/)
|
|
22
|
-
.action(async (ctx) => {
|
|
23
|
-
const message = await service.getMessage();
|
|
24
|
-
await ctx.reply(message);
|
|
25
|
-
});
|
|
1
|
+
import { useCommand } from '@kokkoro/core';
|
|
2
|
+
export const metadata = {
|
|
3
|
+
name: 'kfc',
|
|
4
|
+
description: 'vivo 50',
|
|
5
|
+
};
|
|
6
|
+
export default function KentuckyFriedChicken() {
|
|
7
|
+
useCommand('/疯狂星期四', async (ctx) => {
|
|
8
|
+
const { data } = await ctx.bot.request.get('https://kfc.yuki.sh');
|
|
9
|
+
const { success, message, text } = data;
|
|
10
|
+
return success ? text : message;
|
|
11
|
+
});
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "kokkoro-plugin-kfc",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"@kokkoro/core": "^2.0.1",
|
|
24
|
-
"@types/node": "^18.11.19",
|
|
25
|
-
"axios": "^1.3.2"
|
|
26
|
-
},
|
|
27
|
-
"files": [
|
|
28
|
-
"lib"
|
|
29
|
-
]
|
|
1
|
+
{
|
|
2
|
+
"name": "kokkoro-plugin-kfc",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "vivo 50",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"typings": "lib/index.d.ts",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"bot",
|
|
10
|
+
"kokkoro",
|
|
11
|
+
"kfc",
|
|
12
|
+
"qq"
|
|
13
|
+
],
|
|
14
|
+
"author": "Yuki <admin@yuki.sh>",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@kokkoro/core": "^3.0.10"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc && tsc-alias",
|
|
21
|
+
"build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")"
|
|
22
|
+
}
|
|
30
23
|
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Metadata, useCommand } from '@kokkoro/core';
|
|
2
|
+
|
|
3
|
+
interface Result {
|
|
4
|
+
success: boolean;
|
|
5
|
+
text: string;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const metadata: Metadata = {
|
|
10
|
+
name: 'kfc',
|
|
11
|
+
description: 'vivo 50',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default function KentuckyFriedChicken() {
|
|
15
|
+
useCommand('/疯狂星期四', async ctx => {
|
|
16
|
+
const { data } = await ctx.bot.request.get<Result>('https://kfc.yuki.sh');
|
|
17
|
+
const { success, message, text } = data;
|
|
18
|
+
|
|
19
|
+
return success ? text : message;
|
|
20
|
+
});
|
|
21
|
+
}
|
package/tsconfig.json
ADDED
package/lib/service.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Service = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
class Service {
|
|
9
|
-
plugin;
|
|
10
|
-
/** API */
|
|
11
|
-
api;
|
|
12
|
-
constructor(
|
|
13
|
-
/** 插件 */
|
|
14
|
-
plugin) {
|
|
15
|
-
this.plugin = plugin;
|
|
16
|
-
this.api = 'https://kfc.yuki.sh/api/index';
|
|
17
|
-
}
|
|
18
|
-
async getMessage() {
|
|
19
|
-
let message;
|
|
20
|
-
try {
|
|
21
|
-
const { data } = await axios_1.default.get(this.api);
|
|
22
|
-
message = data;
|
|
23
|
-
}
|
|
24
|
-
catch (error) {
|
|
25
|
-
message = error.message;
|
|
26
|
-
}
|
|
27
|
-
return message;
|
|
28
|
-
}
|
|
29
|
-
async autoSend() {
|
|
30
|
-
const message = await this.getMessage();
|
|
31
|
-
this.plugin.bl.forEach((bot) => {
|
|
32
|
-
const sendQueue = [];
|
|
33
|
-
const uins = [...bot.gl.keys()];
|
|
34
|
-
const uins_length = uins.length;
|
|
35
|
-
for (let i = 0; i < uins_length; i++) {
|
|
36
|
-
const uin = uins[i];
|
|
37
|
-
const info = bot.gl.get(uin);
|
|
38
|
-
const { group_id } = info;
|
|
39
|
-
const { apply, auto_send } = bot.profile.getOption(group_id, 'message');
|
|
40
|
-
if (apply && auto_send) {
|
|
41
|
-
sendQueue.push(bot.sendGroupMsg(group_id, message));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
Promise.allSettled(sendQueue);
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
exports.Service = Service;
|