kokkoro-plugin-hitokoto 0.2.0 → 0.3.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/lib/index.js CHANGED
@@ -1,35 +1,38 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.plugin = void 0;
4
3
  const kokkoro_1 = require("kokkoro");
5
4
  const service_1 = require("./service");
6
- const option = {
7
- apply: true,
8
- lock: false,
9
- auto_send: true,
10
- param: '?c=a&c=b&c=c',
11
- };
12
- exports.plugin = new kokkoro_1.Plugin('hitokoto', option).version(require('../package.json').version);
13
- exports.plugin
14
- .schedule('0 0 0 * * ?', async () => {
15
- const bot_list = (0, kokkoro_1.getBotList)();
16
- const hitokoto = await (0, service_1.getHitokoto)(option.param);
17
- for (const [_, bot] of bot_list) {
18
- const group_list = bot.getGroupList();
19
- // 判断开启服务的群
20
- group_list.forEach(async (group) => {
21
- const { group_id } = group;
22
- const { apply, auto_send } = bot.getOption(group_id, 'hitokoto');
23
- if (apply && auto_send) {
24
- bot.sendGroupMsg(group_id, hitokoto);
25
- }
26
- });
27
- }
28
- })
29
- .command('say', 'group')
5
+ // import { HitokotoOption } from './type';
6
+ // const option: HitokotoOption = {
7
+ // apply: true,
8
+ // lock: false,
9
+ // auto_send: true,
10
+ // param: '?c=a&c=b&c=c',
11
+ // };
12
+ const { version } = require('../package.json');
13
+ const plugin = new kokkoro_1.Plugin('hitokoto');
14
+ plugin
15
+ .version(version);
16
+ plugin
17
+ // .schedule('0 0 0 * * ?', async () => {
18
+ // const bot_list = getBotList();
19
+ // const hitokoto = await getHitokoto(option.param);
20
+ // for (const [_, bot] of bot_list) {
21
+ // const group_list = bot.getGroupList();
22
+ // // 判断开启服务的群
23
+ // group_list.forEach(async group => {
24
+ // const { group_id } = group;
25
+ // const { apply, auto_send } = bot.getOption(group_id, 'hitokoto');
26
+ // if (apply && auto_send) {
27
+ // bot.sendGroupMsg(group_id, hitokoto);
28
+ // }
29
+ // })
30
+ // }
31
+ // })
32
+ .command('say')
30
33
  .description('发送一言')
31
34
  .sugar(/^(来|说)(点|句|段)骚话$/)
32
- .action(async function () {
33
- const hitokoto = await (0, service_1.getHitokoto)(this.option.param);
34
- this.event.reply(hitokoto);
35
+ .action(async (ctx) => {
36
+ const hitokoto = await (0, service_1.getHitokoto)();
37
+ ctx.reply(hitokoto);
35
38
  });
package/lib/service.js CHANGED
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getHitokoto = exports.api = void 0;
7
7
  const axios_1 = __importDefault(require("axios"));
8
+ // import { Hitokoto } from './type';
8
9
  // 定时发送任务
9
10
  exports.api = 'https://v1.hitokoto.cn';
10
11
  async function getHitokoto(param = '') {
package/lib/type.js CHANGED
@@ -1,2 +1,48 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
2
+ // import { Option } from 'kokkoro';
3
+ // export interface HitokotoOption extends Option {
4
+ // auto_send: boolean;
5
+ // param: string;
6
+ // }
7
+ // export interface Hitokoto {
8
+ // // 一言标识
9
+ // id: string;
10
+ // // 一言正文 编码方式 unicode 使用 utf-8
11
+ // hitokoto: string;
12
+ // // 类型
13
+ // type: string;
14
+ // // 一言的出处
15
+ // from: string;
16
+ // // 一言的作者
17
+ // from_who: string;
18
+ // // 添加者
19
+ // creator: string;
20
+ // // 添加者用户标识
21
+ // creator_uid: string;
22
+ // // 审核员标识
23
+ // reviewer: string;
24
+ // // 一言唯一标识;可以链接到 https://hitokoto.cn?uuid=[uuid] (opens new window)查看这个一言的完整信息
25
+ // uuid: string;
26
+ // // 提交方式
27
+ // commit_from: string;
28
+ // // 添加时间
29
+ // created_at: string;
30
+ // // 句子长度
31
+ // length: number;
32
+ // }
33
+ // export interface HitokotoParam {
34
+ // // 句子类型
35
+ // c: string;
36
+ // // 返回编码
37
+ // encode: 'text' | 'json' | 'js' | string;
38
+ // // 字符集
39
+ // charset: 'utf-8' | 'gbk ' | string;
40
+ // // 调用的异步函数
41
+ // callback: string;
42
+ // // 选择器。配合 encode=js 使用
43
+ // select: string;
44
+ // // 返回句子的最小长度(包含)
45
+ // min_length: number;
46
+ // // 返回句子的最大长度(包含)
47
+ // max_length: number;
48
+ // }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "kokkoro-plugin-hitokoto",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "ヒトコト",
5
- "main": "./lib/index.js",
5
+ "main": "lib/index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },