Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow progress updates without images, for 2x and 4x upscales for exa… #242

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/discord.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@ export class WsMessage {
event.prompt = content;
//not image
if (!attachments || attachments.length === 0) {

const progress = content2progress(content);

if (( this.config.UpdateProgressWithoutImage ) && ( progress !== "" )) {
const MJmsg: MJMessage = {
uri: this.config.EmptyImageUri ? this.config.EmptyImageUri : "",
content: content,
flags: flags,
progress: progress,
};
const eventMsg: MJEmit = {
message: MJmsg,
};
this.emitImage(event.nonce, eventMsg);
}
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/interfaces/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export interface MJConfig {
ApiInterval: number;
WebSocket: WebSocketCl;
ImageProxy: string;
UpdateProgressWithoutImage?: boolean;
EmptyImageUri?: string;
}
export interface MJConfigParam {
SalaiToken: string; //DISCORD_TOKEN
Expand All @@ -41,6 +43,8 @@ export interface MJConfigParam {
WsBaseUrl?: string;
fetch?: FetchFn; //Node.js<18 need node.fetch Or proxy
WebSocket?: WebSocketCl; //isomorphic-ws Or proxy
UpdateProgressWithoutImage?: boolean; // Send progress even if no image ( upscale 2x, 4x )
EmptyImageUri?: string; // Uri for image progress when no image is available
}

export const DefaultMJConfig: MJConfig = {
Expand All @@ -58,4 +62,6 @@ export const DefaultMJConfig: MJConfig = {
WsBaseUrl: "wss://gateway.discord.gg/?encoding=json&v=9",
fetch: fetch,
WebSocket: WebSocket,
UpdateProgressWithoutImage: false,
EmptyImageUri: "about:blank",
};