mirror of
https://gitlab.com/bignutty/labscore.git
synced 2025-06-08 06:03:04 -04:00
makesweet
This commit is contained in:
parent
e47952481d
commit
c549cceeec
7 changed files with 297 additions and 28 deletions
|
@ -1,11 +1,14 @@
|
||||||
const { createEmbed } = require("../../../../labscore/utils/embed");
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
const { link } = require("../../../../labscore/utils/markdown");
|
const { link } = require("../../../../labscore/utils/markdown");
|
||||||
const { editOrReply } = require("../../../../labscore/utils/message");
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
const { getUser } = require("../../../../labscore/utils/users");
|
const { flag } = require("../../../../service/makesweet");
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
|
||||||
|
const superagent = require('superagent')
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
name: 'test',
|
name: 'test',
|
||||||
label: 'input',
|
label: 'text',
|
||||||
metadata: {
|
metadata: {
|
||||||
description: 'test',
|
description: 'test',
|
||||||
examples: ['test'],
|
examples: ['test'],
|
||||||
|
@ -13,12 +16,19 @@ module.exports = {
|
||||||
usage: 'test'
|
usage: 'test'
|
||||||
},
|
},
|
||||||
run: async (context, args) => {
|
run: async (context, args) => {
|
||||||
|
if(context.user.id !== "223518178100248576") return;
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, { embeds: [createEmbed("warning", context, "No images found.")] })
|
||||||
|
if(!args.text) args.text = ""
|
||||||
try {
|
try {
|
||||||
return editOrReply(context, createEmbed("default", context, {
|
let mkswt = await flag(image)
|
||||||
description: `${link("https://google.com","Masked Link","Masked Link Tooltip")}`
|
console.log(mkswt.body)
|
||||||
}))
|
return editOrReply(context, { content:"ww", files: [{
|
||||||
|
filename: "makesweet.gif",
|
||||||
|
value: mkswt.body
|
||||||
|
}] })
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
}
|
46
commands/message/image/makesweet/billboard.js
Normal file
46
commands/message/image/makesweet/billboard.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
|
||||||
|
const { billboardCityscape } = require("../../../../service/makesweet");
|
||||||
|
const { STATICS } = require("../../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'billboard',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: 'makesweet billboard',
|
||||||
|
examples: ['billboard'],
|
||||||
|
category: 'image',
|
||||||
|
usage: 'billboard'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
||||||
|
|
||||||
|
let response = await editOrReply(context, createEmbed("loading", context, `Generating image...`))
|
||||||
|
|
||||||
|
if(!args.text) args.text = ""
|
||||||
|
try {
|
||||||
|
const timings = Date.now();
|
||||||
|
let mkswt = await billboardCityscape(image)
|
||||||
|
|
||||||
|
await response.edit({ embeds: [createEmbed("default", context, {
|
||||||
|
image: {
|
||||||
|
url: "attachment://makesweet.gif"
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
iconUrl: STATICS.makesweet,
|
||||||
|
text: `MakeSweet • Took ${((Date.now() - timings) / 1000).toFixed(2)}s`
|
||||||
|
}
|
||||||
|
})], files: [{
|
||||||
|
filename: "makesweet.gif",
|
||||||
|
value: mkswt.body
|
||||||
|
}] })
|
||||||
|
} catch (e) {
|
||||||
|
await response.edit({ embeds: [createEmbed("error", context, e)] })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
46
commands/message/image/makesweet/circuitboard.js
Normal file
46
commands/message/image/makesweet/circuitboard.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
|
||||||
|
const { circuitBoard } = require("../../../../service/makesweet");
|
||||||
|
const { STATICS } = require("../../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'circuitboard',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: 'makesweet circuit board',
|
||||||
|
examples: ['circuitboard'],
|
||||||
|
category: 'image',
|
||||||
|
usage: 'circuitboard'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
||||||
|
|
||||||
|
let response = await editOrReply(context, createEmbed("loading", context, `Generating image...`))
|
||||||
|
|
||||||
|
if(!args.text) args.text = ""
|
||||||
|
try {
|
||||||
|
const timings = Date.now();
|
||||||
|
let mkswt = await circuitBoard(image)
|
||||||
|
|
||||||
|
await response.edit({ embeds: [createEmbed("default", context, {
|
||||||
|
image: {
|
||||||
|
url: "attachment://makesweet.gif"
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
iconUrl: STATICS.makesweet,
|
||||||
|
text: `MakeSweet • Took ${((Date.now() - timings) / 1000).toFixed(2)}s`
|
||||||
|
}
|
||||||
|
})], files: [{
|
||||||
|
filename: "makesweet.gif",
|
||||||
|
value: mkswt.body
|
||||||
|
}] })
|
||||||
|
} catch (e) {
|
||||||
|
await response.edit({ embeds: [createEmbed("error", context, e)] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
46
commands/message/image/makesweet/flag.js
Normal file
46
commands/message/image/makesweet/flag.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
|
||||||
|
const { flag } = require("../../../../service/makesweet");
|
||||||
|
const { STATICS } = require("../../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'flag',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: 'makesweet flag',
|
||||||
|
examples: ['flag'],
|
||||||
|
category: 'image',
|
||||||
|
usage: 'flag'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
||||||
|
|
||||||
|
let response = await editOrReply(context, createEmbed("loading", context, `Generating image...`))
|
||||||
|
|
||||||
|
if(!args.text) args.text = ""
|
||||||
|
try {
|
||||||
|
const timings = Date.now();
|
||||||
|
let mkswt = await flag(image)
|
||||||
|
|
||||||
|
await response.edit({ embeds: [createEmbed("default", context, {
|
||||||
|
image: {
|
||||||
|
url: "attachment://makesweet.gif"
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
iconUrl: STATICS.makesweet,
|
||||||
|
text: `MakeSweet • Took ${((Date.now() - timings) / 1000).toFixed(2)}s`
|
||||||
|
}
|
||||||
|
})], files: [{
|
||||||
|
filename: "makesweet.gif",
|
||||||
|
value: mkswt.body
|
||||||
|
}] })
|
||||||
|
} catch (e) {
|
||||||
|
await response.edit({ embeds: [createEmbed("error", context, e)] })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
46
commands/message/image/makesweet/heartlocket.js
Normal file
46
commands/message/image/makesweet/heartlocket.js
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
const { createEmbed } = require("../../../../labscore/utils/embed");
|
||||||
|
const { editOrReply } = require("../../../../labscore/utils/message");
|
||||||
|
|
||||||
|
const { getRecentImage } = require("../../../../labscore/utils/attachment");
|
||||||
|
|
||||||
|
const { heartLocket } = require("../../../../service/makesweet");
|
||||||
|
const { STATICS } = require("../../../../labscore/utils/statics");
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
name: 'heartlocket',
|
||||||
|
label: 'text',
|
||||||
|
metadata: {
|
||||||
|
description: 'makesweet heart locket',
|
||||||
|
examples: ['heartlocket'],
|
||||||
|
category: 'image',
|
||||||
|
usage: 'heartlocket'
|
||||||
|
},
|
||||||
|
run: async (context, args) => {
|
||||||
|
|
||||||
|
let image = await getRecentImage(context, 50)
|
||||||
|
if(!image) return editOrReply(context, createEmbed("warning", context, "No images found."))
|
||||||
|
|
||||||
|
let response = await editOrReply(context, createEmbed("loading", context, `Generating image...`))
|
||||||
|
|
||||||
|
if(!args.text) args.text = ""
|
||||||
|
try {
|
||||||
|
const timings = Date.now();
|
||||||
|
let mkswt = await heartLocket(args.text, image)
|
||||||
|
|
||||||
|
await response.edit({ embeds: [createEmbed("default", context, {
|
||||||
|
image: {
|
||||||
|
url: "attachment://makesweet.gif"
|
||||||
|
},
|
||||||
|
footer: {
|
||||||
|
iconUrl: STATICS.makesweet,
|
||||||
|
text: `MakeSweet • Took ${((Date.now() - timings) / 1000).toFixed(2)}s`
|
||||||
|
}
|
||||||
|
})], files: [{
|
||||||
|
filename: "makesweet.gif",
|
||||||
|
value: mkswt.body
|
||||||
|
}] })
|
||||||
|
} catch (e) {
|
||||||
|
await response.edit({ embeds: [createEmbed("error", context, e)] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,32 +4,32 @@ const { Hosts } = require('../api/endpoints')
|
||||||
// Update the revision id to break discord cache
|
// Update the revision id to break discord cache
|
||||||
const Statics = Object.freeze({
|
const Statics = Object.freeze({
|
||||||
brands: {
|
brands: {
|
||||||
photofunia: {
|
bing: {
|
||||||
file: "brands/photofunia.png",
|
file: "brands/bing.png",
|
||||||
revision: 1
|
revision: 0
|
||||||
},
|
},
|
||||||
genius: {
|
genius: {
|
||||||
file: "brands/genius.png",
|
file: "brands/genius.png",
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
bing: {
|
|
||||||
file: "brands/bing.png",
|
|
||||||
revision: 0
|
|
||||||
},
|
|
||||||
google: {
|
google: {
|
||||||
file: "brands/google.png",
|
file: "brands/google.png",
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
wolframalpha: {
|
|
||||||
file: "brands/wolframalpha.png",
|
|
||||||
revision: 1
|
|
||||||
},
|
|
||||||
inferkit: {
|
inferkit: {
|
||||||
file: "brands/inferkit.png",
|
file: "brands/inferkit.png",
|
||||||
revision: 0
|
revision: 0
|
||||||
},
|
},
|
||||||
youtube: {
|
makesweet: {
|
||||||
file: "brands/youtube.png",
|
file: "brands/makesweet.png",
|
||||||
|
revision: 0
|
||||||
|
},
|
||||||
|
photofunia: {
|
||||||
|
file: "brands/photofunia.png",
|
||||||
|
revision: 1
|
||||||
|
},
|
||||||
|
tineye: {
|
||||||
|
file: "brands/tineye.png",
|
||||||
revision: 1
|
revision: 1
|
||||||
},
|
},
|
||||||
urbandictionary: {
|
urbandictionary: {
|
||||||
|
@ -40,8 +40,12 @@ const Statics = Object.freeze({
|
||||||
file: "brands/wikihow.png",
|
file: "brands/wikihow.png",
|
||||||
revision: 1
|
revision: 1
|
||||||
},
|
},
|
||||||
tineye: {
|
wolframalpha: {
|
||||||
file: "brands/tineye.png",
|
file: "brands/wolframalpha.png",
|
||||||
|
revision: 1
|
||||||
|
},
|
||||||
|
youtube: {
|
||||||
|
file: "brands/youtube.png",
|
||||||
revision: 1
|
revision: 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,14 +56,15 @@ function staticAsset(static) {
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.STATICS = Object.freeze({
|
module.exports.STATICS = Object.freeze({
|
||||||
photofunia: staticAsset(Statics.brands.photofunia),
|
|
||||||
genius: staticAsset(Statics.brands.genius),
|
|
||||||
bing: staticAsset(Statics.brands.bing),
|
bing: staticAsset(Statics.brands.bing),
|
||||||
|
genius: staticAsset(Statics.brands.genius),
|
||||||
google: staticAsset(Statics.brands.google),
|
google: staticAsset(Statics.brands.google),
|
||||||
wolframalpha: staticAsset(Statics.brands.wolframalpha),
|
|
||||||
inferkit: staticAsset(Statics.brands.inferkit),
|
inferkit: staticAsset(Statics.brands.inferkit),
|
||||||
youtube: staticAsset(Statics.brands.youtube),
|
makesweet: staticAsset(Statics.brands.makesweet),
|
||||||
|
photofunia: staticAsset(Statics.brands.photofunia),
|
||||||
|
tineye: staticAsset(Statics.brands.tineye),
|
||||||
urbandictionary: staticAsset(Statics.brands.urbandictionary),
|
urbandictionary: staticAsset(Statics.brands.urbandictionary),
|
||||||
wikihow: staticAsset(Statics.brands.wikihow),
|
wikihow: staticAsset(Statics.brands.wikihow),
|
||||||
tineye: staticAsset(Statics.brands.tineye)
|
wolframalpha: staticAsset(Statics.brands.wolframalpha),
|
||||||
|
youtube: staticAsset(Statics.brands.youtube)
|
||||||
})
|
})
|
70
service/makesweet.js
Normal file
70
service/makesweet.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
const superagent = require('superagent')
|
||||||
|
|
||||||
|
const effects = [
|
||||||
|
"billboard-cityscape",
|
||||||
|
"circuit-board",
|
||||||
|
"flag",
|
||||||
|
"flying-bear",
|
||||||
|
"heart-locket",
|
||||||
|
"nesting-doll"
|
||||||
|
]
|
||||||
|
|
||||||
|
async function fetchImage(url) {
|
||||||
|
try{
|
||||||
|
let res = await superagent.get(`https://external-content.duckduckgo.com/iu/`)
|
||||||
|
.query({
|
||||||
|
u: url
|
||||||
|
})
|
||||||
|
return res.body
|
||||||
|
}catch(e){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function processMakesweet(effect, args, image) {
|
||||||
|
try{
|
||||||
|
if(image){
|
||||||
|
image = await fetchImage(image)
|
||||||
|
if(!image) throw "Unable to fetch image"
|
||||||
|
|
||||||
|
let res = await superagent.post(`http://api.makesweet.com/make/${effect}`)
|
||||||
|
.set("Authorization", process.env.makesweet)
|
||||||
|
.buffer(true)
|
||||||
|
.query(args)
|
||||||
|
.attach('image', image, 'image.png')
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
let res = await superagent.post(`http://api.makesweet.com/make/${effect}`)
|
||||||
|
.set("Authorization", process.env.makesweet)
|
||||||
|
.buffer(true)
|
||||||
|
.query(args)
|
||||||
|
return res
|
||||||
|
}catch(e){
|
||||||
|
console.log(e)
|
||||||
|
throw "Unable to generate image."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.heartLocket = async (text, url) => {
|
||||||
|
return await processMakesweet("heart-locket", { text: text, textfirst: 1 }, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.billboardCityscape = async (url) => {
|
||||||
|
return await processMakesweet("billboard-cityscape", {}, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.circuitBoard = async (url) => {
|
||||||
|
return await processMakesweet("circuit-board", {}, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.flag = async (url) => {
|
||||||
|
return await processMakesweet("flag", {}, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
/*exports.flyingBear = async (text, url) => {
|
||||||
|
return await processMakesweet("flying-bear", { text: text, textfirst: 1 }, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.nestingDoll = async (text, url) => {
|
||||||
|
return await processMakesweet("nesting-doll", { text: text, textfirst: 1 }, url)
|
||||||
|
}*/
|
Loading…
Add table
Add a link
Reference in a new issue