add message translations feature to ctx

This commit is contained in:
bignutty 2025-01-01 03:45:58 +01:00
parent f71aa434b0
commit 3b34dfcdd4
4 changed files with 127 additions and 28 deletions

View file

@ -11,6 +11,7 @@ const Api = Object.freeze({
GOOGLE_SPEECH_RECOGNIZE: '/google/speech/recognize',
GOOGLE_SPEECH_RECOGNIZE_LABELS: '/google/speech/multirecognize',
GOOGLE_TRANSLATE: '/google/translate/text',
GOOGLE_TRANSLATE_MULTI: '/google/translate/multi',
GOOGLE_VISION_COLORS: '/google/vision/colors',
GOOGLE_VISION_FACES: '/google/vision/faces',
GOOGLE_VISION_LABELS: '/google/vision/labels',

View file

@ -68,6 +68,14 @@ module.exports.googleTranslate = async function(context, text, to, from){
})
}
module.exports.googleTranslateMulti = async function(context, messages, to, from){
return await request(Api.GOOGLE_TRANSLATE_MULTI, "POST", {}, {
messages: messages,
to: to,
from: from
})
}
module.exports.googleVisionColors = async function(context, url){
return await request(Api.GOOGLE_VISION_COLORS, "GET", {}, {
url: url

View file

@ -79,6 +79,7 @@ module.exports.ICONS = Object.freeze({
"flask_mini": "<:ico_subt_flask:1263593669215256597>",
"subtext_lightbulb": "<:ico_subt_lightbulb:1263593690358616084>",
"subtext_translate": "<:ico_subtext_translate:1323844562875187291>",
"button_mag": "<:ico_button_mag:1271212564122173552>",
"button_thermometer": "<:ico_button_thermometer:1263593823016062987>",