kokkoro-plugin-kfc 2.0.0 → 3.0.1
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 +1 -1
- package/README.md +29 -23
- package/package.json +17 -12
- package/src/index.ts +41 -15
- package/lib/index.js +0 -12
- package/tsconfig.json +0 -13
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
# kokkoro-plugin-kfc
|
|
2
|
-
|
|
3
|
-
vivo 50
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```shell
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
+
```text
|
|
14
|
+
/疯狂星期四
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
发送「/疯狂星期四」,插件会随机返回一条疯狂星期四文案。
|
|
18
|
+
|
|
19
|
+
## 快捷方式
|
|
20
|
+
|
|
21
|
+
消息中包含以下任意一类关键词时,插件也会随机返回一条疯狂星期四文案。
|
|
22
|
+
|
|
23
|
+
- 付款梗,例如「V我50」、「微我五十」或「vivo50」
|
|
24
|
+
- 肯德基,例如「肯德基」或「KFC」
|
|
25
|
+
- 星期四,例如「周四」、「星期四」、「木曜日」或「Thursday」
|
|
26
|
+
|
|
27
|
+
北京时间每周四,消息中出现「麦当劳」、「金拱门」、「华莱士」、「汉堡王」、「德克士」或「塔斯汀」时,也会随机返回一条疯狂星期四文案。
|
|
28
|
+
|
|
29
|
+
群聊需要开启「获取群内全部消息」权限。
|
package/package.json
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kokkoro-plugin-kfc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
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
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
"
|
|
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
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
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,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useCommand } from '@kokkoro/core';
|
|
2
2
|
|
|
3
|
-
interface
|
|
4
|
-
success: boolean;
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
interface CrazyThursday {
|
|
4
|
+
readonly success: boolean;
|
|
5
|
+
readonly message: string;
|
|
6
|
+
readonly text: string;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
const KFC_API = new URL('https://kfc.yuki.sh');
|
|
10
|
+
|
|
11
|
+
const PAYMENT = /(?:vivo|[v微]\s*(?:我|me)?)\s*(?:50|五十)/i;
|
|
12
|
+
const KFC = /(?:肯德基|kfc)/i;
|
|
13
|
+
const THURSDAY = /(?:周四|星期四|木曜日|thursday)/i;
|
|
14
|
+
const BURGER_BRANDS = /(?:麦当劳|金拱门|华莱士|汉堡王|德克士|塔斯汀)/i;
|
|
15
|
+
|
|
16
|
+
const KEYWORDS = [PAYMENT, KFC, THURSDAY];
|
|
17
|
+
const SHORTCUT = new RegExp([...KEYWORDS, BURGER_BRANDS].map(pattern => pattern.source).join('|'), 'i');
|
|
18
|
+
const WEEKDAY_FORMAT = new Intl.DateTimeFormat('en-US', {
|
|
19
|
+
timeZone: 'Asia/Shanghai',
|
|
20
|
+
weekday: 'long',
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
async function getCrazyThursday() {
|
|
24
|
+
const response = await fetch(KFC_API);
|
|
13
25
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(`接口请求失败,状态码 ${response.status}`);
|
|
28
|
+
}
|
|
29
|
+
const { success, message, text } = <CrazyThursday>await response.json();
|
|
18
30
|
|
|
19
|
-
|
|
20
|
-
});
|
|
31
|
+
return success ? text : message;
|
|
21
32
|
}
|
|
33
|
+
|
|
34
|
+
function shouldTrigger(content: string) {
|
|
35
|
+
if (KEYWORDS.some(pattern => pattern.test(content))) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
return WEEKDAY_FORMAT.format(new Date()) === 'Thursday' && BURGER_BRANDS.test(content);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default () => {
|
|
42
|
+
useCommand('/疯狂星期四', context => {
|
|
43
|
+
if (shouldTrigger(context.content)) {
|
|
44
|
+
return getCrazyThursday();
|
|
45
|
+
}
|
|
46
|
+
}).shortcut(SHORTCUT);
|
|
47
|
+
};
|
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
|
-
}
|