From adbc3a9d332295b76c9847b1c461e5eef73ba980 Mon Sep 17 00:00:00 2001 From: bignutty <3515180-bignutty@users.noreply.gitlab.com> Date: Wed, 21 Aug 2024 02:55:28 +0200 Subject: [PATCH] add new search types --- commands/interaction/slash/search/google.js | 22 +++++++++++++ commands/message/search/google.js | 36 +++++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/commands/interaction/slash/search/google.js b/commands/interaction/slash/search/google.js index 7658310..a6e0243 100644 --- a/commands/interaction/slash/search/google.js +++ b/commands/interaction/slash/search/google.js @@ -33,6 +33,10 @@ const SEARCH_CARD_TYPES = { DICTIONARY: 7, FUNBOX_COIN_FLIP: 10, FUNBOX_COLOR_PICKER: 11, + DATA_GENERIC: 20, + DATA_FINANCE: 21, + DATA_DICTIONARY: 22, + DATA_TRANSLATE: 23 } // TODO: create a favicon() util @@ -163,6 +167,24 @@ function createSearchResultPage(context, result, doodle){ footer: renderFooter(context, doodle) }) break; + case SEARCH_CARD_TYPES.DATA_GENERIC: + res = createEmbed("default", context, { + description: `-# ${result.fact.category} › **${result.fact.type}**\n# ${result.fact.result}`, + footer: renderFooter(context, doodle) + }) + + if(result.fact.icon) res.thumbnail = { url: result.fact.icon } + + break; + case SEARCH_CARD_TYPES.DATA_FINANCE: + res = createEmbed("default", context, { + description: `-# $${result.finance.ticker} (${result.finance.exchange})\n${result.finance.title}\n# ${result.finance.price}$\n**${result.finance.change}**`, + footer: { + // TODO: googlefinance Static Asset + iconUrl: STATICS.google, + text: `${result.finance.time} • Google Finance • ${context.application.name}` + } + }) default: res = createEmbed("error", context, "Unknown GoogleResult Type: " + result.type) break; diff --git a/commands/message/search/google.js b/commands/message/search/google.js index 7482056..1aeee18 100644 --- a/commands/message/search/google.js +++ b/commands/message/search/google.js @@ -23,6 +23,7 @@ function renderFooter(context, doodle){ } // These have to be synced with the backend (search_service/endpoints/google). + const SEARCH_CARD_TYPES = { UNKNONW: 0, SEARCH_RESULT: 1, @@ -34,6 +35,10 @@ const SEARCH_CARD_TYPES = { DICTIONARY: 7, FUNBOX_COIN_FLIP: 10, FUNBOX_COLOR_PICKER: 11, + DATA_GENERIC: 20, + DATA_FINANCE: 21, + DATA_DICTIONARY: 22, + DATA_TRANSLATE: 23 } // TODO: create a favicon() util @@ -163,6 +168,37 @@ function createSearchResultPage(context, result, doodle){ }, footer: renderFooter(context, doodle) }) + break; + case SEARCH_CARD_TYPES.DATA_GENERIC: + res = createEmbed("default", context, { + description: `-# ${result.fact.category} > ${result.fact.type}\n# ${result.fact.result}`, + thumbnail: { + url: result.card.thumbnail + }, + footer: renderFooter(context, doodle) + }) + + if(result.fact.icon) res.thumbnail = { url: result.fact.icon } + break; + case SEARCH_CARD_TYPES.DATA_GENERIC: + res = createEmbed("default", context, { + description: `-# ${result.fact.category} › **${result.fact.type}**\n# ${result.fact.result}`, + footer: renderFooter(context, doodle) + }) + + if(result.fact.icon) res.thumbnail = { url: result.fact.icon } + + break; + case SEARCH_CARD_TYPES.DATA_FINANCE: + res = createEmbed("default", context, { + description: `-# $${result.finance.ticker} (${result.finance.exchange})\n${result.finance.title}\n# ${result.finance.price}$\n**${result.finance.change}**`, + footer: { + // TODO: googlefinance Static Asset + iconUrl: STATICS.google, + text: `${result.finance.time} • Google Finance • ${context.application.name}` + } + }) + break; default: res = createEmbed("error", context, "Unknown GoogleResult Type: " + result.type)