mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
update design, add bard word filter
This commit is contained in:
parent
32ef0811ab
commit
fb2d4dbb37
4 changed files with 18 additions and 5 deletions
|
@ -9,6 +9,8 @@ const { iconPill, smallIconPill, icon } = require('../../../labscore/utils/markd
|
||||||
|
|
||||||
const { Permissions } = require("detritus-client/lib/constants");
|
const { Permissions } = require("detritus-client/lib/constants");
|
||||||
|
|
||||||
|
const BLOCKED_PHRASES = process.env.BARD_BLOCKLIST.split(';')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'bard',
|
name: 'bard',
|
||||||
label: 'text',
|
label: 'text',
|
||||||
|
@ -32,11 +34,13 @@ module.exports = {
|
||||||
|
|
||||||
let input = args.text;
|
let input = args.text;
|
||||||
|
|
||||||
|
for(const p of BLOCKED_PHRASES) if(input.toLowerCase().includes(p)) return await editOrReply(context, createEmbed("error", context, "Query includes blocked phrases. This incident will be reported."));
|
||||||
|
|
||||||
let inputDisplay = args.text.replace(/\n/g, ' ')
|
let inputDisplay = args.text.replace(/\n/g, ' ')
|
||||||
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_bard", context, inputDisplay))
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_bard))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/google/bard`)
|
let res = await superagent.post(`${process.env.AI_SERVER}/google/bard`)
|
||||||
.set({
|
.set({
|
||||||
|
|
|
@ -57,7 +57,7 @@ module.exports = {
|
||||||
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
if(inputDisplay.length >= 50) inputDisplay = inputDisplay.substr(0,50) + '...'
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await editOrReply(context, createEmbed("ai_bard", context, inputDisplay))
|
await editOrReply(context, createEmbed("ai_custom", context, STATIC_ICONS.ai_palm_idle))
|
||||||
|
|
||||||
let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2`)
|
let res = await superagent.post(`${process.env.AI_SERVER}/google/palm2`)
|
||||||
.set({
|
.set({
|
||||||
|
@ -87,7 +87,7 @@ module.exports = {
|
||||||
embeds:[createEmbed("defaultNoFooter", context, {
|
embeds:[createEmbed("defaultNoFooter", context, {
|
||||||
author: {
|
author: {
|
||||||
name: inputDisplay,
|
name: inputDisplay,
|
||||||
iconUrl: STATIC_ICONS.ai_bard_idle
|
iconUrl: STATIC_ICONS.ai_palm_idle
|
||||||
},
|
},
|
||||||
description: description.join('\n'),
|
description: description.join('\n'),
|
||||||
footer: {
|
footer: {
|
||||||
|
|
|
@ -88,10 +88,10 @@ const embedTypes = Object.freeze({
|
||||||
color: COLORS.embed
|
color: COLORS.embed
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ai_bard": (context) => {
|
"ai_custom": (context) => {
|
||||||
return {
|
return {
|
||||||
author: {
|
author: {
|
||||||
iconUrl: STATIC_ICONS.ai_bard,
|
iconUrl: STATIC_ICONS.ai,
|
||||||
name: ``
|
name: ``
|
||||||
},
|
},
|
||||||
image: {
|
image: {
|
||||||
|
@ -113,6 +113,10 @@ module.exports.createEmbed = function(type, context, content){
|
||||||
return emb
|
return emb
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(["ai_custom"].includes(type)){
|
||||||
|
emb.author.iconUrl = content
|
||||||
|
}
|
||||||
|
|
||||||
if(["errordetail"].includes(type)){
|
if(["errordetail"].includes(type)){
|
||||||
emb.author.name = content.error
|
emb.author.name = content.error
|
||||||
emb.description = content.content
|
emb.description = content.content
|
||||||
|
|
|
@ -136,6 +136,10 @@ const Statics = Object.freeze({
|
||||||
file: "icons/core/ico_notice_bard_idle.gif",
|
file: "icons/core/ico_notice_bard_idle.gif",
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
|
ai_palm_idle: {
|
||||||
|
file: "icons/core/ico_notice_palm_idle.png",
|
||||||
|
revision: 0
|
||||||
|
},
|
||||||
warning: {
|
warning: {
|
||||||
file: "icons/core/ico_notice_warning.png",
|
file: "icons/core/ico_notice_warning.png",
|
||||||
revision: 0
|
revision: 0
|
||||||
|
@ -181,6 +185,7 @@ module.exports.STATIC_ICONS = Object.freeze({
|
||||||
ai: staticAsset(Statics.icons.ai),
|
ai: staticAsset(Statics.icons.ai),
|
||||||
ai_bard: staticAsset(Statics.icons.ai_bard),
|
ai_bard: staticAsset(Statics.icons.ai_bard),
|
||||||
ai_bard_idle: staticAsset(Statics.icons.ai_bard_idle),
|
ai_bard_idle: staticAsset(Statics.icons.ai_bard_idle),
|
||||||
|
ai_palm_idle: staticAsset(Statics.icons.ai_palm_idle),
|
||||||
warning: staticAsset(Statics.icons.warning)
|
warning: staticAsset(Statics.icons.warning)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue