onebots 0.2.4 → 0.2.5

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/README.md CHANGED
@@ -79,5 +79,5 @@ node ./index.js
79
79
  | /remove | get | uin,force | 移除机器人,force为true时,将删除机器人data目录 |
80
80
 
81
81
  # 鸣谢
82
- 1. [takayama-lily/icqq](https://github.com/takayama-lily/icqq) 底层服务支持
83
- 2. [takayama-lily/onebot](https://github.com/takayama-lily/node-onebot) oneBots原先版本
82
+ 1. [icqqjs/icqq](https://github.com/icqqjs/icqq) 底层服务支持
83
+ 2. [takayama-lily/onebot](https://github.com/takayama-lily/node-onebot) oneBot V11 原先版本
package/lib/onebot.js CHANGED
@@ -92,7 +92,6 @@ class OneBot extends events_1.EventEmitter {
92
92
  });
93
93
  this.client.trap('system.login.device', function deviceHelper(e) {
94
94
  console.log('请选择验证方式:1.短信验证 2.url验证');
95
- this.sendSmsCode();
96
95
  process.stdin.once('data', (buf) => {
97
96
  const input = e.toString().trim();
98
97
  if (input === '1') {
@@ -104,7 +103,7 @@ class OneBot extends events_1.EventEmitter {
104
103
  }
105
104
  else {
106
105
  console.log(`请前往:${e.url} 完成验证后回车继续`);
107
- process.stdin.once('data', buf => {
106
+ process.stdin.once('data', () => {
108
107
  this.login();
109
108
  });
110
109
  }
@@ -125,7 +124,6 @@ class OneBot extends events_1.EventEmitter {
125
124
  this.off('system.login.error', errorHandler);
126
125
  });
127
126
  this.client.trap('system.login.slider', function sliderHelper(e) {
128
- console.log('滑块验证地址:' + e.url);
129
127
  console.log('请输入滑块验证返回的ticket');
130
128
  process.stdin.once('data', (e) => {
131
129
  this.submitSlider(e.toString().trim());
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FriendAction = void 0;
4
- const utils_1 = require("../../../service/V11/action/utils");
4
+ const utils_1 = require("../../../service/V11/utils");
5
5
  class FriendAction {
6
6
  /**
7
7
  * 发送私聊消息
@@ -10,12 +10,12 @@ class FriendAction {
10
10
  * @param message_id {string} 引用的消息ID
11
11
  */
12
12
  async sendPrivateMsg(user_id, message, message_id) {
13
- const msg = message ? await this.client.getMsg(message_id) : undefined;
13
+ const msg = message_id ? await this.client.getMsg(message_id) : undefined;
14
14
  const { element, quote, music, share } = await utils_1.processMessage.apply(this.client, [message, msg]);
15
15
  if (music)
16
- await this.client.pickUser(user_id).shareMusic(music.data.platform, music.data.id);
16
+ await this.client.pickFriend(user_id).shareMusic(music.data.platform, music.data.id);
17
17
  if (share)
18
- await this.client.pickUser(user_id).shareUrl(music.data);
18
+ await this.client.pickFriend(user_id).shareUrl(music.data);
19
19
  if (element.length) {
20
20
  return await this.client.sendPrivateMsg(user_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
21
21
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupAction = void 0;
4
- const utils_1 = require("../../../service/V11/action/utils");
4
+ const utils_1 = require("../../../service/V11/utils");
5
5
  class GroupAction {
6
6
  /**
7
7
  * 发送群聊消息
@@ -10,7 +10,7 @@ class GroupAction {
10
10
  * @param message_id {string} 引用的消息ID
11
11
  */
12
12
  async sendGroupMsg(group_id, message, message_id) {
13
- const msg = message ? await this.client.getMsg(message_id) : undefined;
13
+ const msg = message_id ? await this.client.getMsg(message_id) : undefined;
14
14
  const { element, quote, music, share } = await utils_1.processMessage.apply(this.client, [message, msg]);
15
15
  if (music)
16
16
  await this.client.pickGroup(group_id).shareMusic(music.data.platform, music.data.id);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processMessage = void 0;
4
- const utils_1 = require("../../../utils");
4
+ const utils_1 = require("../../utils");
5
5
  const utils_2 = require("icqq-cq-enable/lib/utils");
6
6
  async function processMessage(message, source) {
7
7
  const element = typeof message === 'string' ? (0, utils_2.fromCqcode)(message) : (0, utils_2.fromSegment)(message);
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FriendAction = void 0;
4
- const utils_1 = require("../../../service/V12/action/utils");
4
+ const utils_1 = require("../../../service/V12/utils");
5
5
  class FriendAction {
6
6
  getUserInfo(user_id) {
7
7
  return this.client.getStrangerInfo(user_id);
@@ -18,9 +18,9 @@ class FriendAction {
18
18
  async sendPrivateMsg(user_id, message, source) {
19
19
  let { element, quote, music, share } = await utils_1.processMessage.apply(this.client, [message, source]);
20
20
  if (music)
21
- await this.client.pickUser(user_id).shareMusic(music.data.platform, music.data.id);
21
+ await this.client.pickFriend(user_id).shareMusic(music.data.platform, music.data.id);
22
22
  if (share)
23
- await this.client.pickUser(user_id).shareUrl(music.data);
23
+ await this.client.pickFriend(user_id).shareUrl(music.data);
24
24
  if (element.length) {
25
25
  return await this.client.sendPrivateMsg(user_id, element, quote ? await this.client.getMsg(quote.data.message_id) : undefined);
26
26
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupAction = void 0;
4
- const utils_1 = require("../../../service/V12/action/utils");
4
+ const utils_1 = require("../../../service/V12/utils");
5
5
  class GroupAction {
6
6
  /**
7
7
  * 发送群聊消息
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GuildAction = void 0;
4
- const utils_1 = require("../../../service/V12/action/utils");
4
+ const utils_1 = require("../../../service/V12/utils");
5
5
  class GuildAction {
6
6
  getGuildList() {
7
7
  return this.client.getGuildList();
@@ -38,7 +38,7 @@ export declare class V12 extends EventEmitter implements OneBot.Base {
38
38
  sub_type: string;
39
39
  } & Omit<V12.BotEventMap[E], E>;
40
40
  dispatch(data: Record<string, any>): void;
41
- apply(req: any): Promise<string>;
41
+ apply(req: V12.RequestAction): Promise<string>;
42
42
  private _httpRequestHandler;
43
43
  /**
44
44
  * 快速操作
@@ -215,4 +215,9 @@ export declare namespace V12 {
215
215
  type: string;
216
216
  sub_type: string;
217
217
  } & Omit<BotEventMap[K], K>;
218
+ type RequestAction = {
219
+ action: string;
220
+ params: Record<string, any>;
221
+ echo?: number;
222
+ };
218
223
  }
@@ -1,5 +1,5 @@
1
1
  import { Client, MessageElem } from "icqq";
2
- import { V12 } from "../../../service/V12";
2
+ import { V12 } from "../../service/V12";
3
3
  export declare function processMessage(this: Client, message: V12.Sendable, source?: V12.SegmentElem<'reply'>): Promise<{
4
4
  element: MessageElem[];
5
5
  music?: V12.SegmentElem<'music'>;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.processMessage = void 0;
4
- const V12_1 = require("../../../service/V12");
5
- const utils_1 = require("../../../utils");
4
+ const V12_1 = require("../../service/V12");
5
+ const utils_1 = require("../../utils");
6
6
  async function processMessage(message, source) {
7
7
  let segments = [].concat(message).map(m => {
8
8
  if (typeof m === 'string')
package/lib/utils.d.ts CHANGED
@@ -4,13 +4,13 @@ export declare function transformObj(obj: any, callback: any): any;
4
4
  export declare function deepClone<T extends any>(obj: T): T;
5
5
  export declare function pick<T extends object, K extends keyof T>(source: T, keys?: Iterable<K>, forced?: boolean): Pick<T, K>;
6
6
  export declare function omit<T, K extends keyof T>(source: T, keys?: Iterable<K>): Omit<T, K>;
7
+ export declare function toLine<T extends string>(name: T): string;
7
8
  export interface Class {
8
9
  new (...args: any[]): any;
9
10
  }
10
11
  export declare function Mixin(base: Class, ...classes: Class[]): Class;
11
12
  export declare function toHump(action: string): string;
12
13
  export declare function remove<T>(list: T[], item: T): void;
13
- export declare function toLine(name: string): string;
14
14
  export declare function toBool(v: any): boolean;
15
15
  export declare function uuid(): string;
16
16
  export declare function protectedFields<T>(source: T, ...keys: (keyof T)[]): T;
package/lib/utils.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getProperties = exports.protectedFields = exports.uuid = exports.toBool = exports.toLine = exports.remove = exports.toHump = exports.Mixin = exports.omit = exports.pick = exports.deepClone = exports.transformObj = exports.deepMerge = exports.version = void 0;
26
+ exports.getProperties = exports.protectedFields = exports.uuid = exports.toBool = exports.remove = exports.toHump = exports.Mixin = exports.toLine = exports.omit = exports.pick = exports.deepClone = exports.transformObj = exports.deepMerge = exports.version = void 0;
27
27
  const crypto = __importStar(require("crypto"));
28
28
  const packageJson = require('../package.json');
29
29
  exports.version = packageJson.version;
@@ -114,6 +114,10 @@ function omit(source, keys) {
114
114
  return result;
115
115
  }
116
116
  exports.omit = omit;
117
+ function toLine(name) {
118
+ return name.replace(/([A-Z])/g, "_$1").toLowerCase();
119
+ }
120
+ exports.toLine = toLine;
117
121
  function Mixin(base, ...classes) {
118
122
  classes.forEach(ctr => {
119
123
  Object.getOwnPropertyNames(ctr.prototype).forEach(name => {
@@ -137,10 +141,6 @@ function remove(list, item) {
137
141
  list.splice(idx, 1);
138
142
  }
139
143
  exports.remove = remove;
140
- function toLine(name) {
141
- return name.replace(/([A-Z])/g, "_$1").toLowerCase();
142
- }
143
- exports.toLine = toLine;
144
144
  function toBool(v) {
145
145
  if (v === "0" || v === "false")
146
146
  v = false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "onebots",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "基于icqq的多例oneBot实现",
5
5
  "engines": {
6
6
  "node": ">=16"
@@ -14,6 +14,9 @@
14
14
  "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
15
15
  "dev": "ts-node-dev -r tsconfig-paths/register ./src/bin.ts -c config.yaml",
16
16
  "pub": "npm publish --access public",
17
+ "docs:dev": "vitepress dev docs --port 8989",
18
+ "docs:build": "vitepress build docs",
19
+ "docs:preview": "vitepress preview docs",
17
20
  "test": "echo \"Error: no test specified\" && exit 1"
18
21
  },
19
22
  "repository": {
@@ -40,7 +43,8 @@
40
43
  "ts-node-dev": "latest",
41
44
  "tsc-alias": "latest",
42
45
  "tsconfig-paths": "latest",
43
- "typescript": "latest"
46
+ "typescript": "latest",
47
+ "vitepress": "^1.0.0-alpha.72"
44
48
  },
45
49
  "files": [
46
50
  "/lib/**/*.js",
@@ -50,7 +54,7 @@
50
54
  ],
51
55
  "dependencies": {
52
56
  "@koa/router": "^10.1.1",
53
- "icqq": "^0.2.0",
57
+ "icqq": "^0.3.6",
54
58
  "icqq-cq-enable": "^1.0.0",
55
59
  "js-yaml": "^4.1.0",
56
60
  "koa": "^2.13.4",