mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
Update Translate, Labels and SafetyLabels to use the current design language
This commit is contained in:
parent
40cc793ed0
commit
c4eedec190
4 changed files with 154 additions and 18 deletions
|
@ -1,6 +1,7 @@
|
||||||
const { googleVisionLabels } = require("../../../labscore/api");
|
const { googleVisionLabels } = require("../../../labscore/api");
|
||||||
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
||||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { pill } = require("../../../labscore/utils/markdown");
|
||||||
const { editOrReply } = require("../../../labscore/utils/message");
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
const { STATICS } = require("../../../labscore/utils/statics");
|
const { STATICS } = require("../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
@ -22,21 +23,17 @@ module.exports = {
|
||||||
|
|
||||||
let labels = []
|
let labels = []
|
||||||
for(const l of label.response.body.labels){
|
for(const l of label.response.body.labels){
|
||||||
labels.push({
|
labels.push(pill(`${l.score.toString().substr(2,2)}.${l.score.toString().substr(3,1)}%`) + ' ' + pill(l.name))
|
||||||
name: l.name,
|
|
||||||
value: `${l.score.toString().substr(2,2)}.${l.score.toString().substr(3,1)}%`,
|
|
||||||
inline: true
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
return editOrReply(context, {
|
return editOrReply(context, {
|
||||||
embeds: [createEmbed("default", context, {
|
embeds: [createEmbed("default", context, {
|
||||||
fields: labels,
|
description: labels.join('\n'),
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: image
|
url: image
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
iconUrl: STATICS.google,
|
iconUrl: STATICS.google,
|
||||||
text: `Google Cloud Vision • ${context.application.name} • Took ${label.timings}s`
|
text: `Google Cloud Vision • ${context.application.name}`
|
||||||
}
|
}
|
||||||
})]
|
})]
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const { googleVisionSafetyLabels } = require("../../../labscore/api");
|
const { googleVisionSafetyLabels } = require("../../../labscore/api");
|
||||||
|
const { GOOGLE_CLOUD_SAFETY_LABELS, GOOGLE_CLOUD_SAFETY_LABELS_NAMES } = require("../../../labscore/constants");
|
||||||
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
const { getRecentImage } = require("../../../labscore/utils/attachment");
|
||||||
const { createEmbed } = require("../../../labscore/utils/embed");
|
const { createEmbed } = require("../../../labscore/utils/embed");
|
||||||
|
const { icon, pill, iconPill } = require("../../../labscore/utils/markdown");
|
||||||
const { editOrReply } = require("../../../labscore/utils/message");
|
const { editOrReply } = require("../../../labscore/utils/message");
|
||||||
const { STATICS } = require("../../../labscore/utils/statics");
|
const { STATICS } = require("../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
@ -22,21 +24,21 @@ module.exports = {
|
||||||
|
|
||||||
let labels = []
|
let labels = []
|
||||||
for(const l of Object.keys(label.response.body.labels)){
|
for(const l of Object.keys(label.response.body.labels)){
|
||||||
labels.push({
|
let rating = GOOGLE_CLOUD_SAFETY_LABELS[label.response.body.labels[l]]
|
||||||
name: l.charAt(0).toUpperCase() + l.slice(1),
|
labels.push([
|
||||||
value: label.response.body.labels[l],
|
pill(GOOGLE_CLOUD_SAFETY_LABELS_NAMES[l]),
|
||||||
inline: true
|
iconPill(rating.icon, rating.name)
|
||||||
})
|
].join(' '))
|
||||||
}
|
}
|
||||||
return editOrReply(context, {
|
return editOrReply(context, {
|
||||||
embeds: [createEmbed("default", context, {
|
embeds: [createEmbed("default", context, {
|
||||||
fields: labels,
|
description: labels.join('\n'),
|
||||||
thumbnail: {
|
thumbnail: {
|
||||||
url: image
|
url: image
|
||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
iconUrl: STATICS.google,
|
iconUrl: STATICS.google,
|
||||||
text: `Google Cloud Vision • ${context.application.name} • Took ${label.timings}s`
|
text: `Google Cloud Vision • ${context.application.name}`
|
||||||
}
|
}
|
||||||
})]
|
})]
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
const { createEmbed } = require('../../../labscore/utils/embed')
|
const { createEmbed } = require('../../../labscore/utils/embed')
|
||||||
const { editOrReply } = require('../../../labscore/utils/message')
|
const { editOrReply } = require('../../../labscore/utils/message')
|
||||||
|
|
||||||
const { codeblock, highlight, icon } = require('../../../labscore/utils/markdown');
|
const { codeblock, highlight, icon, pill } = require('../../../labscore/utils/markdown');
|
||||||
|
|
||||||
const { isSupported } = require('../../../labscore/utils/translate');
|
const { isSupported } = require('../../../labscore/utils/translate');
|
||||||
const { googleTranslate } = require('../../../labscore/api');
|
const { googleTranslate } = require('../../../labscore/api');
|
||||||
const { STATICS } = require('../../../labscore/utils/statics');
|
const { STATICS } = require('../../../labscore/utils/statics');
|
||||||
|
const { TRANSLATE_LANGUAGES, TRANSLATE_LANGUAGE_MAPPINGS } = require('../../../labscore/constants');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'translate',
|
name: 'translate',
|
||||||
|
@ -38,8 +39,11 @@ module.exports = {
|
||||||
|
|
||||||
try{
|
try{
|
||||||
let translate = await googleTranslate(context, content, args.to, args.from)
|
let translate = await googleTranslate(context, content, args.to, args.from)
|
||||||
|
|
||||||
|
let fromFlag = TRANSLATE_LANGUAGE_MAPPINGS[translate.response.body.language.from || args.from] || ''
|
||||||
|
let toFlag = TRANSLATE_LANGUAGE_MAPPINGS[translate.response.body.language.to] || ''
|
||||||
return editOrReply(context, createEmbed("default", context, {
|
return editOrReply(context, createEmbed("default", context, {
|
||||||
description: `${icon("locale")} ${highlight(`${translate.response.body.language.from} -> ${translate.response.body.language.to}`)}\n${codeblock("ansi", [translate.response.body.translation])}`,
|
description: `${icon("locale")} ${fromFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.from || args.from])} ${icon("arrow_right")} ${toFlag} ${pill(TRANSLATE_LANGUAGES[translate.response.body.language.to])}\n${codeblock("ansi", [translate.response.body.translation])}`,
|
||||||
footer: {
|
footer: {
|
||||||
iconUrl: STATICS.google,
|
iconUrl: STATICS.google,
|
||||||
text: `Google Translator • ${context.application.name} • Took ${translate.timings}s`
|
text: `Google Translator • ${context.application.name} • Took ${translate.timings}s`
|
||||||
|
|
|
@ -81,7 +81,17 @@ module.exports.ICONS = Object.freeze({
|
||||||
"like": "<:ico_like:1086443586700181514>",
|
"like": "<:ico_like:1086443586700181514>",
|
||||||
"message": "<:ico_message:1086443588784758844>",
|
"message": "<:ico_message:1086443588784758844>",
|
||||||
"eye": "<:ico_eye:1086443585337036860>",
|
"eye": "<:ico_eye:1086443585337036860>",
|
||||||
"videos": "<:ico_videos:1086449271609503764>"
|
"videos": "<:ico_videos:1086449271609503764>",
|
||||||
|
"question_large": "<:ico_question:1086624956235919391>",
|
||||||
|
"exclaim_0": "<:ico_w0:1086624957586489364>",
|
||||||
|
"exclaim_1": "<:ico_w1:1086624959142580275>",
|
||||||
|
"exclaim_2": "<:ico_w2:1086624961025810485>",
|
||||||
|
"exclaim_3": "<:ico_w3:1086624963047460874>",
|
||||||
|
"exclaim_4": "<:ico_w4:1086624964284788787>",
|
||||||
|
"arrow_up": "<:ico_arrowup:980237911171674193>",
|
||||||
|
"arrow_down": "<:ico_arrowdown:980237911008092160>",
|
||||||
|
"arrow_left": "<:ico_arrowleft:1086628775644647464>",
|
||||||
|
"arrow_right": "<:ico_arrowright:1086628777880191016>",
|
||||||
})
|
})
|
||||||
|
|
||||||
const GUILD_FEATURE_ICONS = Object.freeze({
|
const GUILD_FEATURE_ICONS = Object.freeze({
|
||||||
|
@ -267,6 +277,94 @@ module.exports.IMTRANSLATOR_VOICES = [
|
||||||
{ name: "Korean (Female)", value: "ko" }
|
{ name: "Korean (Female)", value: "ko" }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
module.exports.TRANSLATE_LANGUAGE_MAPPINGS = Object.freeze({
|
||||||
|
'af': '🇿🇦',
|
||||||
|
'sq': '🇦🇱',
|
||||||
|
'am': '🇪🇹',
|
||||||
|
'hy': '🇦🇲',
|
||||||
|
'az': '🇦🇿',
|
||||||
|
'eu': 'Basque',
|
||||||
|
'be': '🇧🇾',
|
||||||
|
'bn': '🇧🇩',
|
||||||
|
'bs': '🇧🇦',
|
||||||
|
'bg': '🇧🇬',
|
||||||
|
'ceb': '🇵🇭',
|
||||||
|
'ny': '🇲🇼',
|
||||||
|
'zh-cn': '🇨🇳',
|
||||||
|
'zh-tw': '🇨🇳',
|
||||||
|
'hr': '🇭🇷',
|
||||||
|
'cs': '🇨🇿',
|
||||||
|
'da': '🇩🇰',
|
||||||
|
'nl': '🇳🇱',
|
||||||
|
'en': '🇺🇸',
|
||||||
|
'et': '🇪🇪',
|
||||||
|
'tl': '🇵🇭',
|
||||||
|
'fi': '🇫🇮',
|
||||||
|
'fr': '🇫🇷',
|
||||||
|
'ka': '🇬🇪',
|
||||||
|
'de': '🇩🇪',
|
||||||
|
'el': '🇬🇷',
|
||||||
|
'ht': '🇭🇹',
|
||||||
|
'ha': '🇳🇬',
|
||||||
|
'iw': '🇮🇱',
|
||||||
|
'hi': '🇮🇳',
|
||||||
|
'hu': '🇭🇺',
|
||||||
|
'is': '🇮🇸',
|
||||||
|
'ig': '🇳🇬',
|
||||||
|
'id': '🇮🇩',
|
||||||
|
'ga': '🇮🇪',
|
||||||
|
'it': '🇮🇹',
|
||||||
|
'ja': '🇯🇵',
|
||||||
|
'jw': '🇮🇩',
|
||||||
|
'kk': '🇰🇿',
|
||||||
|
'km': '🇰🇭',
|
||||||
|
'ko': '🇰🇷',
|
||||||
|
'ky': '🇰🇬',
|
||||||
|
'lo': '🇱🇦',
|
||||||
|
'lv': '🇱🇻',
|
||||||
|
'lt': '🇱🇹',
|
||||||
|
'lb': '🇱🇺',
|
||||||
|
'mk': '🇲🇰',
|
||||||
|
'mg': '🇲🇬',
|
||||||
|
'ms': '🇲🇾',
|
||||||
|
'mt': '🇲🇹',
|
||||||
|
'mi': '🇳🇿',
|
||||||
|
'mr': '🇮🇳',
|
||||||
|
'mn': '🇲🇳',
|
||||||
|
'my': '🇲🇲',
|
||||||
|
'ne': '🇳🇵',
|
||||||
|
'no': '🇳🇴',
|
||||||
|
'ps': '🇦🇫',
|
||||||
|
'fa': '🇮🇷',
|
||||||
|
'pl': '🇵🇱',
|
||||||
|
'pt': '🇵🇹',
|
||||||
|
'ro': '🇷🇴',
|
||||||
|
'ru': '🇷🇺',
|
||||||
|
'sm': '🇼🇸',
|
||||||
|
'gd': '🏴',
|
||||||
|
'sr': '🇷🇸',
|
||||||
|
'st': '🇱🇸',
|
||||||
|
'sn': '🇿🇼',
|
||||||
|
'si': '🇱🇰',
|
||||||
|
'sk': '🇸🇰',
|
||||||
|
'sl': '🇸🇮',
|
||||||
|
'so': '🇸🇴',
|
||||||
|
'es': '🇪🇸',
|
||||||
|
'su': '🇸🇩',
|
||||||
|
'sw': '🇰🇪',
|
||||||
|
'sv': '🇸🇪',
|
||||||
|
'tg': '🇹🇯',
|
||||||
|
'te': '🇮🇳',
|
||||||
|
'th': '🇹🇭',
|
||||||
|
'tr': '🇹🇷',
|
||||||
|
'uk': '🇺🇦',
|
||||||
|
'ur': '🇵🇰',
|
||||||
|
'uz': '🇺🇿',
|
||||||
|
'vi': '🇻🇳',
|
||||||
|
'cy': '🏴',
|
||||||
|
'xh': '🇿🇦',
|
||||||
|
})
|
||||||
|
|
||||||
module.exports.TRANSLATE_LANGUAGES = Object.freeze({
|
module.exports.TRANSLATE_LANGUAGES = Object.freeze({
|
||||||
'auto': 'Automatic',
|
'auto': 'Automatic',
|
||||||
'af': 'Afrikaans',
|
'af': 'Afrikaans',
|
||||||
|
@ -408,3 +506,38 @@ module.exports.EMOJIPEDIA_PLATFORM_TYPE_ALIASES = {
|
||||||
"twemoji": "twitter",
|
"twemoji": "twitter",
|
||||||
"playstation": "sony"
|
"playstation": "sony"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module.exports.GOOGLE_CLOUD_SAFETY_LABELS_NAMES = Object.freeze({
|
||||||
|
"adult": "Explicit Content ",
|
||||||
|
"spoof": "Modified Image ",
|
||||||
|
"medical": "Medical Image ",
|
||||||
|
"violence": "Contains Violence",
|
||||||
|
"racy": "Lewd Content "
|
||||||
|
})
|
||||||
|
|
||||||
|
module.exports.GOOGLE_CLOUD_SAFETY_LABELS = Object.freeze({
|
||||||
|
"UNKNOWN": {
|
||||||
|
icon: "question_large",
|
||||||
|
name: "Unknown "
|
||||||
|
},
|
||||||
|
"VERY_UNLIKELY": {
|
||||||
|
icon: "exclaim_0",
|
||||||
|
name: "Very Unlikely"
|
||||||
|
},
|
||||||
|
"UNLIKELY": {
|
||||||
|
icon: "exclaim_1",
|
||||||
|
name: "Unlikely "
|
||||||
|
},
|
||||||
|
"POSSIBLE": {
|
||||||
|
icon: "exclaim_2",
|
||||||
|
name: "Possible "
|
||||||
|
},
|
||||||
|
"LIKELY": {
|
||||||
|
icon: "exclaim_3",
|
||||||
|
name: "Likely "
|
||||||
|
},
|
||||||
|
"VERY_LIKELY": {
|
||||||
|
icon: "exclaim_4",
|
||||||
|
name: "Very Likely "
|
||||||
|
}
|
||||||
|
})
|
Loading…
Add table
Add a link
Reference in a new issue