mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-11 00:34:33 +00:00
chore: Lint extensions folder.
This commit is contained in:
@@ -3,7 +3,9 @@ import { Urbit } from "@urbit/http-api";
|
||||
let patched = false;
|
||||
|
||||
export function ensureUrbitConnectPatched() {
|
||||
if (patched) return;
|
||||
if (patched) {
|
||||
return;
|
||||
}
|
||||
patched = true;
|
||||
Urbit.prototype.connect = async function patchedConnect() {
|
||||
const resp = await fetch(`${this.url}/~/login`, {
|
||||
|
||||
@@ -121,7 +121,11 @@ export async function sendGroupMessage({
|
||||
export function buildMediaText(text: string | undefined, mediaUrl: string | undefined): string {
|
||||
const cleanText = text?.trim() ?? "";
|
||||
const cleanUrl = mediaUrl?.trim() ?? "";
|
||||
if (cleanText && cleanUrl) return `${cleanText}\n${cleanUrl}`;
|
||||
if (cleanUrl) return cleanUrl;
|
||||
if (cleanText && cleanUrl) {
|
||||
return `${cleanText}\n${cleanUrl}`;
|
||||
}
|
||||
if (cleanUrl) {
|
||||
return cleanUrl;
|
||||
}
|
||||
return cleanText;
|
||||
}
|
||||
|
||||
@@ -180,20 +180,26 @@ export class UrbitSSEClient {
|
||||
if (!this.aborted) {
|
||||
this.logger.error?.(`Stream error: ${String(error)}`);
|
||||
for (const { err } of this.eventHandlers.values()) {
|
||||
if (err) err(error);
|
||||
if (err) {
|
||||
err(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async processStream(body: ReadableStream<Uint8Array> | Readable | null) {
|
||||
if (!body) return;
|
||||
if (!body) {
|
||||
return;
|
||||
}
|
||||
const stream = body instanceof ReadableStream ? Readable.fromWeb(body) : body;
|
||||
let buffer = "";
|
||||
|
||||
try {
|
||||
for await (const chunk of stream) {
|
||||
if (this.aborted) break;
|
||||
if (this.aborted) {
|
||||
break;
|
||||
}
|
||||
buffer += chunk.toString();
|
||||
let eventEnd;
|
||||
while ((eventEnd = buffer.indexOf("\n\n")) !== -1) {
|
||||
@@ -221,7 +227,9 @@ export class UrbitSSEClient {
|
||||
}
|
||||
}
|
||||
|
||||
if (!data) return;
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const parsed = JSON.parse(data) as { id?: number; json?: unknown; response?: string };
|
||||
@@ -229,7 +237,9 @@ export class UrbitSSEClient {
|
||||
if (parsed.response === "quit") {
|
||||
if (parsed.id) {
|
||||
const handlers = this.eventHandlers.get(parsed.id);
|
||||
if (handlers?.quit) handlers.quit();
|
||||
if (handlers?.quit) {
|
||||
handlers.quit();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -241,7 +251,9 @@ export class UrbitSSEClient {
|
||||
}
|
||||
} else if (parsed.json) {
|
||||
for (const { event } of this.eventHandlers.values()) {
|
||||
if (event) event(parsed.json);
|
||||
if (event) {
|
||||
event(parsed.json);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user