kokkoro-plugin-kfc 1.0.2 → 3.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 CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 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.
1
+ MIT License
2
+
3
+ Copyright (c) 2020 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,17 @@
1
- # kokkoro-plugin-kfc
2
-
3
- > 肯德基疯狂星期四段子
4
-
5
- ## 安装
6
-
7
- ```shell
8
- # 切换至 bot 目录
9
- cd bot
10
-
11
- # 安装 npm 包
12
- npm i kokkoro-plugin-kfc
13
- ```
14
-
15
- 有关键字 `v50` 就会自动发送段子
16
-
17
- ## 环境变量
18
-
19
- 你可以在项目根目录下创建 `.env` 文件,修改 `KFC_DATE` 变量来自定义自动发送的时间,默认 `0 0 12 * * 4`(每周四中午十二点)
20
-
21
- ```ini
22
- # KFC 时间
23
- KFC_DATE=0 0 12 * * 4
24
- ```
25
-
26
- 因为插件的定时任务是在初始化时创建的,所以如果你修改了 `KFC_DATE` 变量,需要使用 `reload` 指令将其重新挂载才能生效。
27
-
28
- ## 鸣谢
29
-
30
- https://github.com/whitescent/KFC-Crazy-Thursday
1
+ # kokkoro-plugin-kfc
2
+
3
+ vivo 50
4
+
5
+ ## 安装
6
+
7
+ ```shell
8
+ bun add kokkoro-plugin-kfc
9
+ ```
10
+
11
+ ## 指令
12
+
13
+ 发送「/疯狂星期四」,插件会随机返回一条疯狂星期四文案。
14
+
15
+ ## 快捷方式
16
+
17
+ 消息中出现「周四」「星期四」「木曜日」「肯德基」「KFC」「V我50」「微我五十」「vivo50」或「Thursday」等常见说法时,也会触发插件。
package/package.json CHANGED
@@ -1,30 +1,28 @@
1
- {
2
- "name": "kokkoro-plugin-kfc",
3
- "version": "1.0.2",
4
- "description": "肯德基疯狂星期四段子",
5
- "main": "lib/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/kokkorojs/kokkoro-plugin-kfc.git"
12
- },
13
- "keywords": [
14
- "kokkoro"
15
- ],
16
- "author": "yuki <mail@yuki.sh>",
17
- "license": "MIT",
18
- "bugs": {
19
- "url": "https://github.com/kokkorojs/kokkoro-plugin-kfc/issues"
20
- },
21
- "homepage": "https://github.com/kokkorojs/kokkoro-plugin-kfc#readme",
22
- "devDependencies": {
23
- "@kokkoro/core": "^2.0.1",
24
- "@types/node": "^18.11.19",
25
- "axios": "^1.3.2"
26
- },
27
- "files": [
28
- "lib"
29
- ]
30
- }
1
+ {
2
+ "name": "kokkoro-plugin-kfc",
3
+ "version": "3.0.0",
4
+ "description": "vivo 50",
5
+ "keywords": [
6
+ "bot",
7
+ "kokkoro",
8
+ "kfc",
9
+ "qq"
10
+ ],
11
+ "bugs": "https://github.com/kokkorojs/kokkoro/issues",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/kokkorojs/kokkoro.git",
15
+ "directory": "plugins/kfc"
16
+ },
17
+ "license": "MIT",
18
+ "author": "Yuki <admin@yuki.sh>",
19
+ "type": "module",
20
+ "exports": "./src/index.ts",
21
+ "files": [
22
+ "src"
23
+ ],
24
+ "peerDependencies": {
25
+ "@kokkoro/core": "^3.1.3",
26
+ "typescript": "^6.0.3"
27
+ }
28
+ }
package/src/index.ts ADDED
@@ -0,0 +1,25 @@
1
+ import { useCommand } from '@kokkoro/core';
2
+
3
+ interface CrazyThursday {
4
+ readonly success: boolean;
5
+ readonly message: string;
6
+ readonly text: string;
7
+ }
8
+
9
+ const KFC_API = new URL('https://kfc.yuki.sh');
10
+
11
+ export default () => {
12
+ useCommand('/疯狂星期四', async () => {
13
+ const response = await fetch(KFC_API);
14
+
15
+ if (!response.ok) {
16
+ throw new Error(`接口请求失败,状态码 ${response.status}`);
17
+ }
18
+ const { success, message, text } = <CrazyThursday>await response.json();
19
+
20
+ return success ? text : message;
21
+ })
22
+ .shortcut(/(?:vivo|[v微]\s*(?:我|me)?)\s*(?:50|五十)/i)
23
+ .shortcut(/(?:肯德基|kfc)/i)
24
+ .shortcut(/(?:周四|星期四|木曜日|thursday)/i);
25
+ };
package/lib/index.js DELETED
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@kokkoro/core");
4
- const service_1 = require("./service");
5
- const option = {
6
- apply: true,
7
- lock: false,
8
- auto_send: true,
9
- };
10
- const pkg = require('../package.json');
11
- const plugin = new core_1.Plugin('kfc', option);
12
- const service = new service_1.Service(plugin);
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
- });
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, 'kfc');
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;