kokkoro-plugin-hitokoto 0.3.1 → 1.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.
Files changed (3) hide show
  1. package/README.md +4 -7
  2. package/lib/index.js +9 -13
  3. package/package.json +31 -29
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 安装
6
6
 
7
- ``` shell
7
+ ```shell
8
8
  # 切换至 bot 目录
9
9
  cd bot
10
10
 
@@ -12,16 +12,13 @@ cd bot
12
12
  npm i kokkoro-plugin-hitokoto
13
13
  ```
14
14
 
15
- 在 [kokkoro](https://github.com/kokkorojs/kokkoro) 成功运行并登录后,发送 `mount hitokoto` 即可为 bot 挂载插件
16
- 使用 `hitokoto update <key> <value>` 可修改当前群聊的插件参数,例如关闭每日自动发送 `hitokoto update auto_send false`
17
-
18
15
  ## 参数
19
16
 
20
17
  ```typescript
21
- interface HitokotoSetting {
22
- // 在每天凌晨自动发送
18
+ interface HitokotoOption extends Option {
19
+ /** 在每天凌晨自动发送 */
23
20
  auto_send: boolean;
24
- // 一言接口 get 请求参数,默认 "?c=a&c=b&c=c"
21
+ /** 一言接口 get 请求参数,默认 "?c=a&c=b&c=c" */
25
22
  param: string;
26
23
  }
27
24
  ```
package/lib/index.js CHANGED
@@ -2,28 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const kokkoro_1 = require("kokkoro");
4
4
  const service_1 = require("./service");
5
- const setting = {
5
+ const option = {
6
6
  apply: true,
7
7
  lock: false,
8
8
  auto_send: true,
9
9
  param: '?c=a&c=b&c=c',
10
10
  };
11
11
  const { version } = require('../package.json');
12
- const plugin = new kokkoro_1.Plugin('hitokoto', setting);
12
+ const plugin = new kokkoro_1.Plugin('hitokoto', option);
13
13
  plugin
14
14
  .version(version)
15
15
  .schedule('0 0 0 * * *', async () => {
16
- const hitokoto = await (0, service_1.getHitokoto)(setting.param);
17
- const uins = plugin.getBotUins();
18
- uins.forEach(async (uin) => {
19
- const gl = await plugin.botApi(uin, 'gl');
20
- gl.forEach(async (info) => {
16
+ const hitokoto = await (0, service_1.getHitokoto)(option.param);
17
+ plugin.bl.forEach(bot => {
18
+ bot.gl.forEach(info => {
21
19
  const { group_id } = info;
22
- const { apply } = await plugin.botApi(uin, 'getSetting', group_id, 'hitokoto');
23
- if (!apply) {
24
- return;
20
+ const { apply, auto_send } = bot.getOption(group_id, 'hitokoto');
21
+ if (apply && auto_send) {
22
+ bot.sendGroupMsg(group_id, hitokoto);
25
23
  }
26
- plugin.botApi(uin, 'sendGroupMsg', group_id, hitokoto);
27
24
  });
28
25
  });
29
26
  });
@@ -32,7 +29,6 @@ plugin
32
29
  .description('发送一言')
33
30
  .sugar(/^(来|说)(点|句|段)骚话$/)
34
31
  .action(async (ctx) => {
35
- const param = ctx.setting?.param;
36
- const hitokoto = await (0, service_1.getHitokoto)(param);
32
+ const hitokoto = await (0, service_1.getHitokoto)(ctx.option?.param);
37
33
  ctx.reply(hitokoto);
38
34
  });
package/package.json CHANGED
@@ -1,29 +1,31 @@
1
- {
2
- "name": "kokkoro-plugin-hitokoto",
3
- "version": "0.3.1",
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-hitokoto.git"
12
- },
13
- "keywords": [
14
- "kokkoro"
15
- ],
16
- "author": "yuki",
17
- "license": "MIT",
18
- "bugs": {
19
- "url": "https://github.com/kokkorojs/kokkoro-plugin-hitokoto/issues"
20
- },
21
- "homepage": "https://github.com/kokkorojs/kokkoro-plugin-hitokoto#readme",
22
- "devDependencies": {
23
- "@types/node": "^18.8.5",
24
- "kokkoro": "^1.0.4"
25
- },
26
- "files": [
27
- "lib"
28
- ]
29
- }
1
+ {
2
+ "name": "kokkoro-plugin-hitokoto",
3
+ "version": "1.0.1",
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-hitokoto.git"
12
+ },
13
+ "keywords": [
14
+ "kokkoro",
15
+ "hitokoto"
16
+ ],
17
+ "author": "yuki <mail@yuki.sh>",
18
+ "license": "MIT",
19
+ "bugs": {
20
+ "url": "https://github.com/kokkorojs/kokkoro-plugin-hitokoto/issues"
21
+ },
22
+ "homepage": "https://github.com/kokkorojs/kokkoro-plugin-hitokoto#readme",
23
+ "devDependencies": {
24
+ "@types/node": "^18.11.12",
25
+ "axios": "^1.2.1",
26
+ "kokkoro": "^1.2.2"
27
+ },
28
+ "files": [
29
+ "lib"
30
+ ]
31
+ }