Skip to content

Commit

Permalink
✨ Improved and fixed images
Browse files Browse the repository at this point in the history
Co-authored-by: Aldhanekaa <aldhanekadev@gmail.com>
  • Loading branch information
EvanZhouDev and Aldhanekaa committed Jul 2, 2023
1 parent f27c1cb commit 96e55b0
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,25 +89,32 @@ export const queryBard = async (message, ids = {}) => {
}

// Get important data, and update with important data if set to do so
const jsonChatData = JSON.parse(chatData)[4][0];
const parsedChatData = JSON.parse(chatData);
const bardResponseData = JSON.parse(chatData)[4][0];

let text = jsonChatData[1][0];
let text = bardResponseData[1][0];

let images = jsonChatData[4].map((x) => {
let images = bardResponseData[4]?.map((x) => {
return {
tag: x[2],
url: x[0][5].match(/imgurl=([^&%]+)/)[1],
url: x[3][0][0],
source: {
original: x[0][5].match(/imgurl=([^&%]+)/)[1],
website: x[1][0][0],
name: x[1][1],
favicon: x[1][3]
}
};
}) ?? undefined;
});

return {
content: formatMarkdown(text, images),
images: images,
ids: {
// Make sure kept in order, because using Object.keys() to query above
conversationID: jsonChatData[1][0],
responseID: jsonChatData[1][1],
choiceID: jsonChatData[4][0][0],
conversationID: parsedChatData[1][0],
responseID: parsedChatData[1][1],
choiceID: parsedChatData[4][0][0],
_reqID: parseInt(ids._reqID ?? 0) + 100000,
},
};
Expand Down

0 comments on commit 96e55b0

Please sign in to comment.