chore: initial commit

This commit is contained in:
2026-10-22 17:07:08 +08:00
commit 0acef64f48
200 changed files with 35546 additions and 0 deletions
@@ -0,0 +1,27 @@
import type {Json} from '../../../../types/bot/workflow/workflow.ts';
import type {WorkflowEventTemplate} from '../../../../types/bot/workflow/metadata.ts';
import {describe, output, event_args_output} from '../../metadata.ts';
import {normalize_custom_event} from './custom.ts';
export const config_template: WorkflowEventTemplate = {
name: 'chat', version: '1.0.0', readiness: 'spawned',
i18n: describe('聊天事件', '接收玩家公开聊天,提供用户名、消息内容及安全的原始参数。'),
config: [],
output: {
...output('object', '聊天数据', '从聊天事件前两个字符串参数提取的数据。'),
properties: {
args: event_args_output,
event: output('string', '事件名称', '固定为 chat。'),
username: output('string', '用户名', '发送公开聊天消息的玩家名称。'),
message: output('string', '消息内容', '玩家发送的聊天文本。'),
},
},
};
export function normalize(args: unknown[]): Record<string, Json> | undefined {
if (args.length > 32 || typeof args[0] !== 'string' || typeof args[1] !== 'string') return;
const original = normalize_custom_event('chat', args);
if (!original) return;
const trigger = {...original, username: args[0], message: args[1]};
if (Buffer.byteLength(JSON.stringify(trigger)) <= 65_536) return trigger;
}