alemonjs 2.1.35 → 2.1.36

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.
@@ -42,7 +42,7 @@ export declare const useMessage: <T extends EventKeys>(event: Events[T]) => read
42
42
  export declare const useMember: <T extends EventKeys>(event: Events[T]) => readonly [{}];
43
43
  export declare const useChannel: <T extends EventKeys>(event: Events[T]) => readonly [{}];
44
44
  export declare const useSend: <T extends EventKeys>(event: Events[T]) => (...val: DataEnums[]) => Promise<Result[]>;
45
- export declare const useSends: <T extends EventKeys>(event: Events[T]) => readonly [(params?: any[] | {
45
+ export declare const useSends: <T extends EventKeys>(event: Events[T]) => readonly [(params?: DataEnums[] | {
46
46
  format: Format | DataEnums[];
47
47
  }) => Promise<Result[]>];
48
48
  export declare const unChildren: (name?: string) => void;
package/lib/app/index.js CHANGED
@@ -19,4 +19,4 @@ export { onState, unState, useState } from './hook-use-state.js';
19
19
  export { useObserver, useSubscribe } from './hook-use-subscribe.js';
20
20
  export { createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './message-api.js';
21
21
  export { Format, FormatButtonGroup, FormatMarkDown, createEvent } from './message-format.js';
22
- export { Ark, Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './message-format-old.js';
22
+ export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './message-format-old.js';
@@ -9,7 +9,7 @@ type ResolveFormatFn = (params: MessageParams) => DataEnums[];
9
9
  export declare class MessageControllerImpl {
10
10
  #private;
11
11
  constructor(sendRaw: SendRawFn, resolveFormat: ResolveFormatFn);
12
- get currentFormat(): any[];
12
+ get currentFormat(): DataEnums[];
13
13
  addText(...args: Parameters<typeof Text>): this;
14
14
  addLink(...args: Parameters<typeof Link>): this;
15
15
  addImage(...args: Parameters<typeof Image>): this;
@@ -1,4 +1,4 @@
1
- import { DataMention, DataImage, DataText, DataImageURL, DataImageFile, DataButtonRow, DataButtonGroup, DataButton, DataArkList, DataArkListTip, DataArkListContent, DataArkListItem, DataArkCard, DataArkBigCard, DataMarkDown, DataMarkdownTitle, DataMarkdownSubtitle, DataMarkdownBold, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownStrikethrough, DataMarkdownLink, DataMarkdownImage, DataMarkdownList, DataMarkdownListItem, DataMarkdownBlockquote, DataMarkdownDivider, DataMarkdownNewline, DataLink, DataMarkdownText, DataMarkdownCode, DataMarkdownOriginal, DataAttachment, DataAudio, DataVideo, DataMarkdownMention, DataMarkdownContent, DataMarkdownButton } from '../types';
1
+ import { DataMention, DataImage, DataText, DataImageURL, DataImageFile, DataButtonRow, DataButtonGroup, DataButton, DataMarkDown, DataMarkdownTitle, DataMarkdownSubtitle, DataMarkdownBold, DataMarkdownItalic, DataMarkdownItalicStar, DataMarkdownStrikethrough, DataMarkdownLink, DataMarkdownImage, DataMarkdownList, DataMarkdownListItem, DataMarkdownBlockquote, DataMarkdownDivider, DataMarkdownNewline, DataLink, DataMarkdownText, DataMarkdownCode, DataMarkdownOriginal, DataAttachment, DataAudio, DataVideo, DataMarkdownMention, DataMarkdownContent, DataMarkdownButton } from '../types';
2
2
  export declare const Text: (val: DataText["value"], options?: DataText["options"]) => DataText;
3
3
  export declare const Link: (val: DataLink["value"], options?: DataText["options"]) => DataText;
4
4
  export declare const ImageURL: (val: DataImageURL["value"]) => DataImageURL;
@@ -20,14 +20,6 @@ export declare const BT: {
20
20
  group: (...rows: DataButtonRow[]) => DataButtonGroup;
21
21
  row: (...buttons: DataButton[]) => DataButtonRow;
22
22
  };
23
- export declare const Ark: {
24
- list: (values_0: DataArkListTip, values_1: DataArkListContent) => DataArkList;
25
- listTip: (options: DataArkListTip["value"]) => DataArkListTip;
26
- listContent: (...values: DataArkListContent["value"]) => DataArkListContent;
27
- listItem: (value: DataArkListItem["value"]) => DataArkListItem;
28
- Card: (value: DataArkCard["value"]) => DataArkCard;
29
- BigCard: (value: DataArkBigCard["value"]) => DataArkBigCard;
30
- };
31
23
  declare const Markdown: {
32
24
  (...values: DataMarkDown["value"]): DataMarkDown;
33
25
  text(text: string): DataMarkdownText;
@@ -66,44 +66,6 @@ const ButtonRow = (...buttons) => {
66
66
  Button.group = ButtonGroup;
67
67
  Button.row = ButtonRow;
68
68
  const BT = Button;
69
- const Ark = {
70
- list: (...values) => {
71
- return {
72
- type: 'Ark.list',
73
- value: values
74
- };
75
- },
76
- listTip: (options) => {
77
- return {
78
- type: 'Ark.listTip',
79
- value: options
80
- };
81
- },
82
- listContent: (...values) => {
83
- return {
84
- type: 'Ark.listContent',
85
- value: values
86
- };
87
- },
88
- listItem: (value) => {
89
- return {
90
- type: 'Ark.listItem',
91
- value: value
92
- };
93
- },
94
- Card: (value) => {
95
- return {
96
- type: 'Ark.Card',
97
- value: value
98
- };
99
- },
100
- BigCard: (value) => {
101
- return {
102
- type: 'Ark.BigCard',
103
- value
104
- };
105
- }
106
- };
107
69
  const Markdown = (...values) => {
108
70
  return {
109
71
  type: 'Markdown',
@@ -250,4 +212,4 @@ const Video = (val) => {
250
212
  };
251
213
  };
252
214
 
253
- export { Ark, Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video };
215
+ export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video };
@@ -1,5 +1,5 @@
1
1
  import { BT, MD, Text, Image, Mention, MarkdownOriginal, Attachment, Audio, Video, Link, ImageFile, ImageURL } from './message-format-old.js';
2
- export { Ark, Button, Markdown } from './message-format-old.js';
2
+ export { Button, Markdown } from './message-format-old.js';
3
3
 
4
4
  class FormatButtonGroup {
5
5
  #rows = [];
package/lib/index.js CHANGED
@@ -27,4 +27,4 @@ export { useObserver, useSubscribe } from './app/hook-use-subscribe.js';
27
27
  export { createDataFormat, createEventValue, format, getMessageIntent, sendToChannel, sendToUser } from './app/message-api.js';
28
28
  export { Format, FormatButtonGroup, FormatMarkDown, createEvent } from './app/message-format.js';
29
29
  export { start } from './main.js';
30
- export { Ark, Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './app/message-format-old.js';
30
+ export { Attachment, Audio, BT, Button, Image, ImageFile, ImageURL, Link, MD, Markdown, MarkdownOriginal, Mention, Text, Video } from './app/message-format-old.js';
@@ -1,6 +1,5 @@
1
- import { DataButtonGroup, DataButtonTemplate } from './button';
2
- import { DataArkBigCard, DataArkCard, DataArkList } from './ark';
3
- import { DataMarkDown, DataMarkdownTemplate } from './markdown';
1
+ import { DataButtonGroup } from './button';
2
+ import { DataMarkDown } from './markdown';
4
3
  import { DataImage, DataImageFile, DataImageURL } from './image';
5
4
  import { DataText } from './text';
6
5
  import { DataMention } from './mention';
@@ -14,11 +13,10 @@ export * from './link';
14
13
  export * from './mention';
15
14
  export * from './image';
16
15
  export * from './button';
17
- export * from './ark';
18
16
  export * from './markdown';
19
17
  export * from './markdown-raw';
20
18
  export * from './attachment';
21
19
  export * from './audio';
22
20
  export * from './video';
23
- export type DataEnums = DataText | DataLink | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup | DataButtonTemplate | DataArkList | DataArkCard | DataArkBigCard | DataMarkDown | DataMarkdownTemplate | DataMarkdownOriginal | DataAttachment | DataAudio | DataVideo;
21
+ export type DataEnums = DataText | DataLink | DataImage | DataImageURL | DataImageFile | DataMention | DataButtonGroup | DataMarkDown | DataMarkdownOriginal | DataAttachment | DataAudio | DataVideo;
24
22
  export type MessageDataFormat = DataEnums[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alemonjs",
3
- "version": "2.1.35",
3
+ "version": "2.1.36",
4
4
  "description": "bot script",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",
@@ -69,4 +69,4 @@
69
69
  "type": "git",
70
70
  "url": "https://github.com/lemonade-lab/alemonjs.git"
71
71
  }
72
- }
72
+ }
package/README_CONFIG.md DELETED
@@ -1,204 +0,0 @@
1
- ## 配置相关
2
-
3
- ### 基础配置
4
-
5
- ```yaml
6
- # === 服务器配置 ===
7
- port: 17117 # CBP Websocket 端口 (可选,将允许外部客户端互动)
8
- serverPort: 18110 # Koa 服务器端口(可选,仅在需要Web服务时设置)
9
-
10
- # === 应用配置 ===
11
- input: 'lib/index.js' # 应用入口文件路径,快捷参数 --input
12
- login: 'discord' # 登录平台标识,快捷参数 --login
13
- url: 'ws://127.0.0.1:17117' # CBP服务器连接地址,快捷参数 --url
14
- is_full_receive: false # 是否全量接收消息(用于分流处理)
15
- ```
16
-
17
- ### 权限管理
18
-
19
- ```yaml
20
- # === 主人权限设置 ===
21
- master_id:
22
- '1715713638': true # 通过用户ID设置主人权限
23
- master_key:
24
- '123456': true # 通过用户Key设置主人权限
25
-
26
- # === 机器人标识设置 ===
27
- bot_id:
28
- '1715713638': true # 将指定用户ID标识为机器人
29
- bot_key:
30
- '123456': true # 将指定用户Key标识为机器人
31
- ```
32
-
33
- ### 消息过滤与控制
34
-
35
- ```yaml
36
- # === 禁用控制 ===
37
- disabled_text_regular: '/闭关' # 文本正则匹配,若匹配则禁用所有功能
38
- disabled_selects: # 禁用特定事件类型
39
- 'private.message.create': true # 禁用私聊消息
40
- 'message.create': true # 禁用群组消息
41
- 'interaction.create': true # 禁用交互事件
42
- disabled_user_id: # 禁用特定用户ID
43
- '1715713638': true
44
- disabled_user_key: # 禁用特定用户Key
45
- '123456': true
46
-
47
- # === 文本重定向 ===
48
- redirect_text_regular: '^#' # 文本前缀匹配正则
49
- redirect_text_target: '/' # 将匹配的前缀替换为指定内容
50
-
51
- # === 文本映射规则 ===
52
- mapping_text:
53
- - regular: '/开始游戏' # 匹配的文本
54
- target: '/踏入仙途' # 替换成的文本
55
- - regular: '/帮助'
56
- target: '/help'
57
- ```
58
-
59
- ### 消息处理器配置
60
-
61
- ```yaml
62
- processor:
63
- repeated_event_time: 60000 # 过滤重复MessageId的时间窗口(毫秒)
64
- repeated_user_time: 1000 # 过滤同一用户连续消息的时间窗口(毫秒)
65
- ```
66
-
67
- ### 模块管理
68
-
69
- ```yaml
70
- # === 子模块配置 ===
71
- apps:
72
- 'alemonjs-openai': true # 启用OpenAI模块
73
- 'alemonjs-xianyu': true # 启用咸鱼模块
74
- # 也支持数组格式
75
- # - 'alemonjs-openai'
76
- # - 'alemonjs-xianyu'
77
-
78
- # === 模块特定配置 ===
79
- # 模块配置的键名应与模块名一致
80
- alemonjs-openai:
81
- baseURL: 'https://api.deepseek.com'
82
- apiKey: 'your-api-key-here'
83
- model: 'deepseek-chat'
84
- ```
85
-
86
- ## 快捷参数
87
-
88
- 启动时可使用的快捷参数:
89
-
90
- ```bash
91
- # === 基础参数 ===
92
- # 指定CBP服务器端口
93
- node index.js --port 8080
94
-
95
- # 指定应用服务器端口
96
- node index.js --serverPort 3000
97
-
98
- # 指定入口文件
99
- node index.js --input ./lib/index.js
100
-
101
- # 指定登录平台
102
- node index.js --login discord
103
-
104
- # 指定CBP服务器连接地址
105
- node index.js --url ws://localhost:8080
106
-
107
- # === CBP相关参数 ===
108
- # 指定负载均衡策略
109
- node index.js --loadBalanceStrategy least-connections
110
-
111
- # 启用全量接收模式
112
- node index.js --is_full_receive true
113
-
114
- # === 组合使用示例 ===
115
- # 启动Discord平台,使用轮询策略,端口8080
116
- node index.js --login discord --loadBalanceStrategy round-robin --port 8080
117
- ```
118
-
119
- ## 配置管理工具
120
-
121
- 使用 `alemonc` 命令行工具来管理配置:
122
-
123
- ```bash
124
- # 查看帮助
125
- npx alemonc -h
126
-
127
- # 添加模块
128
- alemonc add apps alemonjs-openai alemonjs-xianyu
129
-
130
- # 移除模块
131
- alemonc remove apps alemonjs-openai
132
-
133
- # 设置配置项
134
- alemonc set login qq
135
- alemonc set discord.token your-token
136
- alemonc set loadBalanceStrategy least-connections
137
-
138
- # 删除配置项
139
- alemonc del discord
140
-
141
- # 获取配置项
142
- alemonc get login
143
- ```
144
-
145
- ## 基础环境变量
146
-
147
- `platform`:`string` - 平台标识,支持的平台类型包括:
148
-
149
- - `discord` - Discord 平台
150
- - `qq` - QQ 平台
151
- - `telegram` - Telegram 平台
152
- - 或其他自定义平台包名(如:`@alemonjs/xxx`)
153
-
154
- `login`:`string` - 登录标识,通常与平台名称相同或为平台的特定实例名
155
-
156
- `url`:`string` - CBP 服务器连接地址,默认为 `ws://127.0.0.1:17117`
157
-
158
- `port`:`string | number` - CBP 服务器端口,默认为 `17117`
159
-
160
- `serverPort`:`string | number` - 应用服务器端口(可选,仅在需要启动 Web 服务时设置)
161
-
162
- `is_full_receive`:`string` - 是否全量接收消息,可选值:`'true'` | `'1'` | `'false'` | `'0'`
163
-
164
- ## 文件路径相关
165
-
166
- `LOG_PATH`:`string` - 日志文件存储路径
167
-
168
- `PKG_PATH`:`string` - package.json 文件路径,默认为当前工作目录下的 `package.json`
169
-
170
- `CFG_PATH`:`string` - 配置文件路径,默认为当前工作目录下的 `alemon.config.yaml`
171
-
172
- ## 运行环境
173
-
174
- `NODE_ENV`:`development | production` - 环境判断,用于区分开发环境和生产环境
175
-
176
- ## CBP
177
-
178
- ChatBot Protocol
179
-
180
- ALemonJS 的核心通信协议,负责客户端与平台之间的消息传输和负载均衡。
181
-
182
- ### CBP 连接配置
183
-
184
- ```yaml
185
- # CBP服务器配置
186
- cbp:
187
- # 连接超时时间(毫秒)
188
- timeout: 180000 # 3分钟
189
-
190
- # 重连间隔(毫秒)
191
- reconnectInterval: 6000 # 6秒
192
-
193
- # 心跳间隔(毫秒)
194
- heartbeatInterval: 18000 # 18秒
195
-
196
- # 健康检查间隔(毫秒)
197
- healthCheckInterval: 30000 # 30秒
198
-
199
- # 连接认证头配置
200
- headers:
201
- user-agent: 'platform' # 平台标识
202
- x-device-id: 'auto-generated' # 设备ID(自动生成)
203
- x-full-receive: '0' # 是否全量接收:'1' 开启,'0' 关闭
204
- ```