alemonjs 1.1.21 → 1.1.23

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/core/apps.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { dirname, basename } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
- import { setAppMessage, setAppArg, setAppCharacter, setAppEvent, setAppPriority } from './cache.js';
3
+ import { setAppMessage, setAppArg, setAppCharacter, setAppEvent, setAppPriority, setAppSlicing } from './cache.js';
4
4
  import { setApp } from './app.js';
5
5
  import { setAllCall } from './call.js';
6
6
  /**
@@ -259,6 +259,24 @@ export function createApp(url) {
259
259
  }
260
260
  return app;
261
261
  },
262
+ /**
263
+ * 消息字符串切割
264
+ * @param str
265
+ * @param reg
266
+ * @returns
267
+ */
268
+ replace: (reg, str) => {
269
+ try {
270
+ setAppSlicing(AppName, {
271
+ str,
272
+ reg
273
+ });
274
+ }
275
+ catch (err) {
276
+ console.error('APP on', err);
277
+ }
278
+ return app;
279
+ },
262
280
  /**
263
281
  * 挂起应用
264
282
  * @returns
package/lib/core/cache.js CHANGED
@@ -120,3 +120,32 @@ export function setAppPriority(key, val) {
120
120
  export function delAppPriority(key) {
121
121
  delete PRIORITY[key];
122
122
  }
123
+ const SLICING = {};
124
+ /**
125
+ * 得到插件默认正则
126
+ * @param key 插件名
127
+ * @returns
128
+ */
129
+ export function getAppSlicing(key) {
130
+ return SLICING[key];
131
+ }
132
+ /**
133
+ * @param key 插件名
134
+ * @param val 规则
135
+ */
136
+ export function setAppSlicing(key, val) {
137
+ if (!Object.prototype.isPrototypeOf.call(SLICING, key))
138
+ SLICING[key] = [];
139
+ // 重复存在的丢掉
140
+ const find = SLICING[key].find(item => `${item.reg}` == `${val.reg}` && item.str == val.str);
141
+ if (find)
142
+ return;
143
+ SLICING[key].push(val);
144
+ }
145
+ /**
146
+ * 删除插件默认正则
147
+ * @param key 插件名
148
+ */
149
+ export function delAppSlicing(key) {
150
+ delete SLICING[key];
151
+ }
@@ -12,6 +12,11 @@ const ApplicationProcessingConfiguration = {
12
12
  event: [],
13
13
  route: '/public/defset',
14
14
  regex: true,
15
+ /**
16
+ * *****
17
+ * tudo
18
+ * ******
19
+ */
15
20
  character: /^(#|\/)/,
16
21
  defaultCharacter: '/'
17
22
  };
@@ -2,7 +2,7 @@ import { join } from 'path';
2
2
  import { writeFile } from 'fs/promises';
3
3
  import { existsSync, mkdirSync, readdirSync } from 'fs';
4
4
  import lodash from 'lodash';
5
- import { getAppArg, getAppEvent, getAppCharacter, getAppMessage, getAppPriority } from './cache.js';
5
+ import { getAppArg, getAppEvent, getAppCharacter, getAppMessage, getAppPriority, getAppSlicing } from './cache.js';
6
6
  import { getApp, delApp, getAppKey } from './app.js';
7
7
  import { EventEnum } from './typings.js';
8
8
  import { conversationHandlers, getConversationState } from './dialogue.js';
@@ -57,9 +57,8 @@ function createPluginHelp() {
57
57
  */
58
58
  async function synthesis(AppName, AppsObj) {
59
59
  // 没有记载
60
- if (!plugins[AppName]) {
60
+ if (!plugins[AppName])
61
61
  plugins[AppName] = [];
62
- }
63
62
  const shield = getAppProCoinfg('event');
64
63
  for (const item in AppsObj) {
65
64
  const keys = new AppsObj[item]();
@@ -382,6 +381,12 @@ export async function InstructionMatching(e) {
382
381
  const character = getAppCharacter(name);
383
382
  const __character = getAppProCoinfg('defaultCharacter');
384
383
  e.msg = e.msg.replace(_character, character ?? __character);
384
+ const arr = getAppSlicing(name);
385
+ if (arr && Array.isArray(arr) && arr.length != 0) {
386
+ for (const item of arr) {
387
+ e.msg = e.msg.replace(item.reg, item.str);
388
+ }
389
+ }
385
390
  }
386
391
  try {
387
392
  if (typeof AppFnc == 'function')
package/lib/core/index.js CHANGED
@@ -10,7 +10,6 @@ export * from './configs.js';
10
10
  export * from './apps.js';
11
11
  export * from './cache.js';
12
12
  export * from './dialogue.js';
13
- export * from './conversation.js';
14
13
  export * from './qrcode.js';
15
14
  export * from './dealmsg.js';
16
15
  export * from './puppeteer.js';
package/lib/core/main.js CHANGED
@@ -3,6 +3,7 @@ export * from './buffer.js';
3
3
  export * from './configs.js';
4
4
  export * from './help.js';
5
5
  export * from './dialogue.js';
6
+ export * from './conversation.js';
6
7
  export * from './ip.js';
7
8
  export * from './plugin.js';
8
9
  export * from './puppeteer.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "1.1.21",
3
+ "version": "1.1.23",
4
4
  "description": "DOCS https://alemonjs.com/",
5
5
  "scripts": {
6
6
  "dev": "ts-node alemon.config.ts",
@@ -82,6 +82,13 @@ export declare function createApps(url: string): {
82
82
  * @param priority 优先级
83
83
  */
84
84
  on: (event: "message" | "GUILD_MEMBERS" | "GUILD_MESSAGE_REACTIONS" | "MESSAGE_AUDIT" | "INTERACTION" | "GUILD" | "GUILD_BOT" | "CHANNEL" | "FORUMS_THREAD" | "FORUMS_POST" | "FORUMS_REPLY" | "MESSAGES" | "MESSAGE_BUTTON" | "AUDIO_FREQUENCY" | "AUDIO_MICROPHONE", call: (e: AMessage) => any, priority?: number) => any;
85
+ /**
86
+ * 消息字符串切割
87
+ * @param str
88
+ * @param reg
89
+ * @returns
90
+ */
91
+ replace: (reg: RegExp, str: string) => any;
85
92
  /**
86
93
  * 挂起应用
87
94
  * @returns
@@ -149,6 +156,13 @@ export declare function createApp(url: string): {
149
156
  * @param priority 优先级
150
157
  */
151
158
  on: (event: (typeof EventEnum)[number], call: (e: AMessage) => any, priority?: number) => any;
159
+ /**
160
+ * 消息字符串切割
161
+ * @param str
162
+ * @param reg
163
+ * @returns
164
+ */
165
+ replace: (reg: RegExp, str: string) => any;
152
166
  /**
153
167
  * 挂起应用
154
168
  * @returns
@@ -83,3 +83,25 @@ export declare function setAppPriority(key: string, val: number): void;
83
83
  * @param key 插件名
84
84
  */
85
85
  export declare function delAppPriority(key: string): void;
86
+ /**
87
+ * 得到插件默认正则
88
+ * @param key 插件名
89
+ * @returns
90
+ */
91
+ export declare function getAppSlicing(key: string): {
92
+ str: string;
93
+ reg: RegExp;
94
+ }[];
95
+ /**
96
+ * @param key 插件名
97
+ * @param val 规则
98
+ */
99
+ export declare function setAppSlicing(key: string, val: {
100
+ str: string;
101
+ reg: RegExp;
102
+ }): void;
103
+ /**
104
+ * 删除插件默认正则
105
+ * @param key 插件名
106
+ */
107
+ export declare function delAppSlicing(key: string): void;
@@ -33,10 +33,12 @@ interface ApplicationProcessingOpsion {
33
33
  event: string[];
34
34
  /**
35
35
  * 起始符特性
36
+ * @deprecated
36
37
  */
37
38
  character: RegExp;
38
39
  /**
39
40
  * 默认特征
41
+ * @deprecated
40
42
  */
41
43
  defaultCharacter: '/' | '#';
42
44
  }
@@ -10,7 +10,6 @@ export * from './configs.js';
10
10
  export * from './apps.js';
11
11
  export * from './cache.js';
12
12
  export * from './dialogue.js';
13
- export * from './conversation.js';
14
13
  export * from './qrcode.js';
15
14
  export * from './dealmsg.js';
16
15
  export * from './puppeteer.js';
@@ -3,6 +3,7 @@ export * from './buffer.js';
3
3
  export * from './configs.js';
4
4
  export * from './help.js';
5
5
  export * from './dialogue.js';
6
+ export * from './conversation.js';
6
7
  export * from './ip.js';
7
8
  export * from './plugin.js';
8
9
  export * from './puppeteer.js';