node-karin 0.3.3 → 0.3.4

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.
@@ -45,9 +45,8 @@ export class MessageHandler extends EventHandler {
45
45
  if (app.event && !this.filtEvent(app.event)) { continue }
46
46
  /** 正则匹配 */
47
47
  for (const v of app.rule) {
48
- /** 这里的lastIndex是为了防止正则无法从头开始匹配 */
49
- v.reg.lastIndex = 0
50
- if (v.reg.test(this.e.msg)) {
48
+ const reg = v.reg
49
+ if (reg.test(this.e.msg)) {
51
50
  /** 检查黑白名单插件 */
52
51
  if ('GroupCD' in this.config && !review.PluginEnable(app, this.config)) { continue }
53
52
  /** 判断子事件 */
@@ -21,7 +21,7 @@ export interface PluginRule {
21
21
  /**
22
22
  * - 命令正则
23
23
  */
24
- reg: RegExp;
24
+ reg: string | RegExp;
25
25
  /**
26
26
  * - 命令执行方法名称
27
27
  */
@@ -6,7 +6,6 @@ export const button = async (e) => {
6
6
  const info = loader.PluginList[v]
7
7
  for (const v of info.button) {
8
8
  const reg = v.reg
9
- /** 这里的lastIndex是为了防止正则无法从头开始匹配 */
10
9
  if (reg.test(e.msg)) {
11
10
  try {
12
11
  let res
@@ -28,8 +28,9 @@ export declare const handler: {
28
28
  * @param key 事件键
29
29
  * @param args 自定义参数 一般用来传递e之类的
30
30
  */
31
- call(key: string, args?: {
32
- e?: EventType<unknown>;
31
+ call(key: string, args: {
32
+ [key: string]: any;
33
+ e?: import("../index.js").KarinMessage | undefined;
33
34
  }): Promise<any>;
34
35
  /**
35
36
  * 检查是否存在指定键的事件处理器
@@ -65,7 +65,7 @@ export const handler = new (class EventHandler {
65
65
  * @param key 事件键
66
66
  * @param args 自定义参数 一般用来传递e之类的
67
67
  */
68
- async call (key, args = {}) {
68
+ async call (key, args) {
69
69
  let res
70
70
  for (const v of loader.handlerIds[key] || []) {
71
71
  const info = loader.PluginList[v.index]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-karin",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "private": false,
5
5
  "description": "基于 Kritor 进行开发的nodejs机器人框架",
6
6
  "homepage": "https://github.com/KarinJS/Karin",