diff --git a/core/grpc_plugins.go b/core/grpc_plugins.go index 0897705..d0cd3ff 100644 --- a/core/grpc_plugins.go +++ b/core/grpc_plugins.go @@ -388,7 +388,7 @@ var typeat = `declare class Sender { allow_users?: string[]; prohibit_users?: string[]; persistent?: boolean; - }): Promise; + }): Promise; holdOn(str: string): string; reply(content: string): Promise; action(options: any): Promise; @@ -433,8 +433,8 @@ declare class Adapter { constructor(options: { platform?: string; bot_id?: string; - replyHandler?: (message: Message) => string | undefined; - actionHandler?: (message: Message) => string | undefined; + replyHandler?: (message: Message) => string | undefined | Promise; + actionHandler?: (message: Message) => string | undefined | Promise; }); setActionHandler(func: (action: {}) => any): void; receive(message: Message): Promise; @@ -444,7 +444,21 @@ declare class Adapter { } declare let sender: Sender; declare function sleep(ms: number | undefined): Promise; -export { Adapter, Bucket, sender, sleep, console }; +interface CQItem { + type: string; + params: {}; +} +declare let utils: { + parseCQText: (text: string, prefix?: string) => (string | CQItem)[]; +}; +declare let console: { + log(...args: any[]): void; + info(...args: any[]): void; + error(...args: any[]): void; + debug(...args: any[]): void; +}; +export { Adapter, Bucket, sender, sleep, utils, console }; + ` func defaultScript(title string) string { diff --git a/core/web.go b/core/web.go index 01b2c80..ac5bb87 100644 --- a/core/web.go +++ b/core/web.go @@ -84,6 +84,7 @@ func initWeb() { if _, err := os.Stat(dir); err != nil { //执行压缩 return } + dir = strings.ReplaceAll(dir, "\\", "/") ss := strings.Split(dir, "/") name := ss[len(ss)-1] buf := new(bytes.Buffer) diff --git a/proto3/sillygirl.d.ts b/proto3/sillygirl.d.ts index 6798556..763e304 100644 --- a/proto3/sillygirl.d.ts +++ b/proto3/sillygirl.d.ts @@ -84,11 +84,12 @@ declare class Adapter { } declare let sender: Sender; declare function sleep(ms: number | undefined): Promise; +interface CQItem { + type: string; + params: {}; +} declare let utils: { - parseCQText: (text: string, prefix?: string) => (string | { - type: string; - params: any; - })[]; + parseCQText: (text: string, prefix?: string) => (string | CQItem)[]; }; declare let console: { log(...args: any[]): void; diff --git a/proto3/sillygirl.js b/proto3/sillygirl.js index b9ebf21..46265d1 100644 --- a/proto3/sillygirl.js +++ b/proto3/sillygirl.js @@ -676,23 +676,22 @@ let utils = { }, }; exports.utils = utils; -let slog = (type, ...args) => { -}; +let slog = (type, ...args) => { }; let console = { log(...args) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, ''); + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console(new srpc_1.srpc.ConsoleRequest({ type: "log", content, plugin_id }), (err, resp) => { }); }, info(...args) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, ''); + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console(new srpc_1.srpc.ConsoleRequest({ type: "info", content, plugin_id }), (err, resp) => { }); }, error(...args) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, ''); + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console(new srpc_1.srpc.ConsoleRequest({ type: "error", content, plugin_id }), (err, resp) => { }); }, debug(...args) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, ''); + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console(new srpc_1.srpc.ConsoleRequest({ type: "debug", content, plugin_id }), (err, resp) => { }); }, }; diff --git a/proto3/sillygirl.ts b/proto3/sillygirl.ts index fa1a34b..921604b 100644 --- a/proto3/sillygirl.ts +++ b/proto3/sillygirl.ts @@ -749,11 +749,16 @@ class Console { debug = (message?: any, ...optionalParams: any[]) => {}; } +interface CQItem { + type: string; + params: {}; +} + let utils = { parseCQText: (text: string, prefix = "CQ") => { const cqRegex = new RegExp(`\\[${prefix}:(\\w+)(.*?)\\]`, "g"); const cqMatches = text.matchAll(cqRegex); - const result = []; + const result: (CQItem | string)[] = []; let lastIndex = 0; for (const match of cqMatches) { @@ -784,38 +789,36 @@ let utils = { }, }; -let slog = (type: string, ...args: any[]) => { - -}; +let slog = (type: string, ...args: any[]) => {}; let console = { log(...args: any[]) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, '') + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console( new srpc.ConsoleRequest({ type: "log", content, plugin_id }), (err, resp) => {} - ) + ); }, info(...args: any[]) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, '') + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console( new srpc.ConsoleRequest({ type: "info", content, plugin_id }), (err, resp) => {} - ) + ); }, error(...args: any[]) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, '') + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console( new srpc.ConsoleRequest({ type: "error", content, plugin_id }), (err, resp) => {} - ) + ); }, debug(...args: any[]) { - const content = args.reduce((acc, arg) => acc + ' ' + arg, '') + const content = args.reduce((acc, arg) => acc + " " + arg, ""); client.Console( new srpc.ConsoleRequest({ type: "debug", content, plugin_id }), (err, resp) => {} - ) + ); }, };