alemonjs 2.0.0-rc.76 → 2.0.0-rc.78

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.
@@ -94,6 +94,17 @@ const expendEvent = async (valueEvent, select, next) => {
94
94
  });
95
95
  }
96
96
  }
97
+ // 消息类型数据
98
+ if (select == 'message.create' || select == 'private.message.create') {
99
+ if (obj?.regular) {
100
+ const reg = new RegExp(obj.regular);
101
+ if (!reg.test(valueEvent['MessageText'])) {
102
+ // 继续
103
+ await nextEvent();
104
+ return;
105
+ }
106
+ }
107
+ }
97
108
  if (!res.current) {
98
109
  // 继续
99
110
  await nextEvent();
@@ -130,6 +141,17 @@ const expendEvent = async (valueEvent, select, next) => {
130
141
  try {
131
142
  const obj = await import(`file://${file.path}`);
132
143
  const res = obj?.default;
144
+ // 消息类型数据
145
+ if (select == 'message.create' || select == 'private.message.create') {
146
+ if (obj?.regular) {
147
+ const reg = new RegExp(obj.regular);
148
+ if (!reg.test(valueEvent['MessageText'])) {
149
+ // 继续
150
+ await nextEvent();
151
+ return;
152
+ }
153
+ }
154
+ }
133
155
  if (!res.current) {
134
156
  // 继续
135
157
  await nextEvent();
@@ -1,6 +1,7 @@
1
1
  import '../global.js';
2
2
  import { User } from '../typing/event/base/user.js';
3
3
  import { DataEnums } from '../typing/message/index.js';
4
+ import { Current } from '../typing/event/index.js';
4
5
  import { AEvents } from '../typing/event/map.js';
5
6
 
6
7
  /**
@@ -23,13 +24,13 @@ declare const useSend: (event: {
23
24
  * @param option
24
25
  * @returns
25
26
  */
26
- declare const useSubscribe: <T extends keyof AEvents>(event: any, select: T) => ((callback: (e: AEvents[T], next: Function) => any, keys: (keyof AEvents[T])[]) => void)[];
27
+ declare const useSubscribe: <T extends keyof AEvents>(event: any, select: T) => ((callback: Current<T>, keys: (keyof AEvents[T])[]) => void)[];
27
28
  /**
28
29
  *
29
30
  * @param event
30
31
  * @param option
31
32
  * @returns
32
33
  */
33
- declare const useObserver: <T extends keyof AEvents>(event: any, option: T) => (callback: (e: AEvents[T], next: Function) => any, keys: (keyof AEvents[T])[]) => void;
34
+ declare const useObserver: <T extends keyof AEvents>(event: any, option: T) => (callback: Current<T>, keys: (keyof AEvents[T])[]) => void;
34
35
 
35
36
  export { useMention, useObserver, useSend, useSubscribe };
package/lib/config.d.ts CHANGED
@@ -17,12 +17,12 @@ declare class ConfigCore {
17
17
  /**
18
18
  * package.json
19
19
  */
20
- get package(): any;
20
+ get package(): null;
21
21
  /**
22
22
  * 命令行参数
23
23
  */
24
24
  get argv(): {
25
- [key: string]: string | true;
25
+ [key: string]: string | true | undefined;
26
26
  };
27
27
  }
28
28
  /**
@@ -36,4 +36,4 @@ declare const getConfig: () => typeof ConfigCore.prototype;
36
36
  */
37
37
  declare const getConfigValue: () => any;
38
38
 
39
- export { getConfig, getConfigValue };
39
+ export { ConfigCore, getConfig, getConfigValue };
package/lib/config.js CHANGED
@@ -22,6 +22,8 @@ class ConfigCore {
22
22
  * @returns
23
23
  */
24
24
  #update() {
25
+ if (!this.#dir)
26
+ return this.#value;
25
27
  // 读取配置文件
26
28
  const dir = join(process.cwd(), this.#dir);
27
29
  logger.info('config read', dir);
@@ -119,4 +121,4 @@ const getConfig = () => {
119
121
  */
120
122
  const getConfigValue = () => getConfig()?.value;
121
123
 
122
- export { getConfig, getConfigValue };
124
+ export { ConfigCore, getConfig, getConfigValue };
package/lib/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export { useMention, useObserver, useSend, useSubscribe } from './app/hook-use-a
9
9
  export { Ark, Button, ButtonBox, Embed, Emoji, File, Image, Link, Mention, Text, Video, Voice } from './app/hook-message-format.js';
10
10
  export { createHash, useUserHashKey } from './app/utils.js';
11
11
  export { getIoRedis } from './db/redis.js';
12
- export { getConfig, getConfigValue } from './config.js';
12
+ export { ConfigCore, getConfig, getConfigValue } from './config.js';
13
13
  export { ChildrenCycle, EventCycle, Next } from './typing/cycle/index.js';
14
14
  export { Channel, Guild } from './typing/event/base/guild.js';
15
15
  export { Message, MessageOpen, MessageText } from './typing/event/base/message.js';
package/lib/index.js CHANGED
@@ -2,7 +2,7 @@ import './global.js';
2
2
  import { join, dirname } from 'path';
3
3
  import { readFileSync, existsSync } from 'fs';
4
4
  import { getConfig } from './config.js';
5
- export { getConfigValue } from './config.js';
5
+ export { ConfigCore, getConfigValue } from './config.js';
6
6
  import { getDirFiles } from './app/event-files.js';
7
7
  export { defineBot } from './app/event-bot.js';
8
8
  export { defineChildren } from './app/event-chidren.js';
@@ -125,7 +125,7 @@ const start = async (input = 'lib/index.js') => {
125
125
  if (typeof platform == 'boolean')
126
126
  return;
127
127
  // module
128
- if (cfg.value?.apps && Array.isArray(cfg.value.apps)) {
128
+ if (cfg.value && cfg.value?.apps && Array.isArray(cfg.value.apps)) {
129
129
  for (const app of cfg.value?.apps) {
130
130
  moduleChildrenFiles(app);
131
131
  }
@@ -24,4 +24,4 @@ type OnObserverValue<T extends keyof AEvents> = {
24
24
  select: T[] | T;
25
25
  };
26
26
 
27
- export type { OnMiddlewareType, OnMiddlewareValue, OnObserverType, OnObserverValue, OnResponseType, OnResponseValue };
27
+ export type { Current, OnMiddlewareType, OnMiddlewareValue, OnObserverType, OnObserverValue, OnResponseType, OnResponseValue };
@@ -1,10 +1,11 @@
1
+ type Value = {
2
+ keys: {
3
+ [key: string]: string | number | boolean;
4
+ };
5
+ current: Function;
6
+ };
1
7
  type SubscribeMap = {
2
- [key: string]: {
3
- keys: {
4
- [key: string]: string | number | boolean;
5
- };
6
- current: Function;
7
- }[];
8
+ [key: string]: (Value | undefined)[];
8
9
  };
9
10
  type Subscribe = {
10
11
  create: SubscribeMap;
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.0.0-rc.76",
3
+ "version": "2.0.0-rc.78",
4
4
  "description": "alemonjs bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
+ "scripts": {
10
+ "build": "node bundle.js"
11
+ },
9
12
  "dependencies": {
10
13
  "chalk": "^5.3.0",
11
14
  "ioredis": "^5.4.1",
@@ -15,6 +18,13 @@
15
18
  "typescript": "^5.5.3",
16
19
  "yaml": "^2.5.1"
17
20
  },
21
+ "devDependencies": {
22
+ "@rollup/plugin-typescript": "^11.1.6",
23
+ "lvyjs": "^0.2.13",
24
+ "rollup": "^4.18.1",
25
+ "rollup-plugin-dts": "^6.1.1",
26
+ "tsx": "^4.19.1"
27
+ },
18
28
  "types": "lib",
19
29
  "exports": {
20
30
  ".": {
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "include": ["src/**/*"],
3
+ "extends": "lvyjs/tsconfig.json"
4
+ }