kokkoro-plugin-kfc 2.0.0 → 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,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2023 Yuki
3
+ Copyright (c) 2020 Yuki
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,23 +1,17 @@
1
- # kokkoro-plugin-kfc
2
-
3
- vivo 50
4
-
5
- **Install:**
6
-
7
- ```shell
8
- npm i kokkoro-plugin-kfc
9
- ```
10
-
11
- **Usage:**
12
-
13
- ```javascript
14
- import { mountPlugin } from '@kokkoro/core';
15
-
16
- await mountPlugin('kokkoro-plugin-kfc');
17
- ```
18
-
19
- **Command:**
20
-
21
- 格式:`/疯狂星期四`
22
- 场景:群聊 & 频道
23
- 功能:随机输出肯德基疯狂星期四段子
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,23 +1,28 @@
1
1
  {
2
2
  "name": "kokkoro-plugin-kfc",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "vivo 50",
5
- "type": "module",
6
- "main": "lib/index.js",
7
- "typings": "lib/index.d.ts",
8
5
  "keywords": [
9
6
  "bot",
10
7
  "kokkoro",
11
8
  "kfc",
12
9
  "qq"
13
10
  ],
14
- "author": "Yuki <admin@yuki.sh>",
15
- "license": "MIT",
16
- "devDependencies": {
17
- "@kokkoro/core": "^3.0.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"
18
16
  },
19
- "scripts": {
20
- "build": "tsc && tsc-alias",
21
- "build:watch": "tsc && (concurrently \"tsc -w\" \"tsc-alias -w\")"
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"
22
27
  }
23
- }
28
+ }
package/src/index.ts CHANGED
@@ -1,21 +1,25 @@
1
- import { Metadata, useCommand } from '@kokkoro/core';
1
+ import { useCommand } from '@kokkoro/core';
2
2
 
3
- interface Result {
4
- success: boolean;
5
- text: string;
6
- message: string;
3
+ interface CrazyThursday {
4
+ readonly success: boolean;
5
+ readonly message: string;
6
+ readonly text: string;
7
7
  }
8
8
 
9
- export const metadata: Metadata = {
10
- name: 'kfc',
11
- description: 'vivo 50',
12
- };
9
+ const KFC_API = new URL('https://kfc.yuki.sh');
10
+
11
+ export default () => {
12
+ useCommand('/疯狂星期四', async () => {
13
+ const response = await fetch(KFC_API);
13
14
 
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;
15
+ if (!response.ok) {
16
+ throw new Error(`接口请求失败,状态码 ${response.status}`);
17
+ }
18
+ const { success, message, text } = <CrazyThursday>await response.json();
18
19
 
19
20
  return success ? text : message;
20
- });
21
- }
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,12 +0,0 @@
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/tsconfig.json DELETED
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.base",
3
- "compilerOptions": {
4
- "rootDir": "src",
5
- "baseUrl": ".",
6
- "paths": {
7
- "@/*": ["src/*"]
8
- },
9
- "declaration": false,
10
- "outDir": "lib"
11
- },
12
- "include": ["src"]
13
- }