Skip to content

Commit

Permalink
Merge pull request #186 from erictik/Action-needed-to-continue
Browse files Browse the repository at this point in the history
Action needed to continue or Pending mod message
  • Loading branch information
zcpua authored Jul 14, 2023
2 parents 7be8799 + 54708b1 commit 36a6e65
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
17 changes: 8 additions & 9 deletions example/imagine-err.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ async function main() {
Debug: true,
});
await client.init();
const msg = await client.Imagine(
`https://images.guapitu.com/chatgpt/5b9b907a/d3297338-ae3e-4276-9bd9-3b6ca27cedcf.png
https://images.guapitu.com/chatgpt/762a2db4/459d52f1-23fd-41c3-a912-317e65155fcc.png
https://images.guapitu.com/chatgpt/f86613ac/2e2497ae-9906-44d9-8396-e41abab2f47b.png
cat`,
(uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
}
);
// `https://images.guapitu.com/chatgpt/5b9b907a/d3297338-ae3e-4276-9bd9-3b6ca27cedcf.png
// https://images.guapitu.com/chatgpt/762a2db4/459d52f1-23fd-41c3-a912-317e65155fcc.png
// https://images.guapitu.com/chatgpt/f86613ac/2e2497ae-9906-44d9-8396-e41abab2f47b.png
// cat`
const prompt = `%s %sTiny cute isometric Hcia illustration, a girl with long white hair, smile, seawater, colorful bubbles, dreamy portrait, Teana punk, more details, fiber tracking, snail core, Kuvshinov Ilya, yakamoz emoji, soft lighting, soft colors, matte clay, blender 3d, pastel background --v 5.1 --ar 1:1 --s 350 --q 1`;
const msg = await client.Imagine(prompt, (uri: string, progress: string) => {
console.log("loading", uri, "progress", progress);
});
console.log({ msg });
}
main().catch((err) => {
Expand Down
1 change: 1 addition & 0 deletions src/banned.words.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// https://tokenizedhq.com/list-of-banned-words-in-midjourney/
// https://www.greataiprompts.com/imageprompt/list-of-banned-words-in-midjourney/
export const bannedWords = [
"hot slut",
"blood",
"twerk",
"making love",
Expand Down
38 changes: 37 additions & 1 deletion src/discord.ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
formatInfo,
formatOptions,
formatPrompts,
nextNonce,
uriToHash,
} from "./utls";
import { VerifyHuman } from "./verify.human";
Expand Down Expand Up @@ -139,6 +140,12 @@ export class WsMessage {
this.log("embeds[0].color", color);
switch (color) {
case 16711680: //error
if (title == "Action needed to continue") {
return this.continue(message);
} else if (title == "Pending mod message") {
return this.continue(message);
}

const error = new Error(description);
this.EventError(id, error);
return;
Expand Down Expand Up @@ -174,6 +181,7 @@ export class WsMessage {

this.messageUpdate(message);
}

private messageUpdate(message: any) {
// this.log("messageUpdate", message);
const {
Expand Down Expand Up @@ -298,13 +306,34 @@ export class WsMessage {
}
}
}
//continue click appeal or Acknowledged
private async continue(message: any) {
const { components, id, flags, nonce } = message;
const appeal = components[0]?.components[0];
this.log("appeal", appeal);
if (appeal) {
var newnonce = nextNonce();
const httpStatus = await this.MJApi.CustomApi({
msgId: id,
customId: appeal.custom_id,
flags,
nonce: newnonce,
});
this.log("appeal.httpStatus", httpStatus);
if (httpStatus == 204) {
this.on(newnonce, (data) => {
this.emit(nonce, data);
});
}
}
}
private async verifyHuman(message: any) {
const { HuggingFaceToken } = this.config;
if (HuggingFaceToken === "" || !HuggingFaceToken) {
this.log("HuggingFaceToken is empty");
return;
}
const { embeds, components, id, flags } = message;
const { embeds, components, id, flags, nonce } = message;
const uri = embeds[0].image.url;
const categories = components[0].components;
const classify = categories.map((c: any) => c.label);
Expand All @@ -314,11 +343,18 @@ export class WsMessage {
const custom_id = categories.find(
(c: any) => c.label === category
).custom_id;
var newnonce = nextNonce();
const httpStatus = await this.MJApi.CustomApi({
msgId: id,
customId: custom_id,
flags,
nonce: newnonce,
});
if (httpStatus == 204) {
this.on(newnonce, (data) => {
this.emit(nonce, data);
});
}
this.log("verifyHumanApi", httpStatus, custom_id, message.id);
}
}
Expand Down

0 comments on commit 36a6e65

Please sign in to comment.