diff --git a/source/plugins/community/fortune/README.md b/source/plugins/community/fortune/README.md new file mode 100644 index 00000000..3eff2a87 --- /dev/null +++ b/source/plugins/community/fortune/README.md @@ -0,0 +1,12 @@ + + + +## ➡️ Available options + + + + +## ℹ️ Examples workflows + + + diff --git a/source/plugins/community/fortune/examples.yml b/source/plugins/community/fortune/examples.yml new file mode 100644 index 00000000..ba6ed84f --- /dev/null +++ b/source/plugins/community/fortune/examples.yml @@ -0,0 +1,9 @@ +- name: Fortune + uses: lowlighter/metrics@latest + with: + filename: metrics.plugin.fortune.svg + token: NOT_NEEDED + base: "" + plugin_fortune: yes + prod: + skip: true diff --git a/source/plugins/community/fortune/index.mjs b/source/plugins/community/fortune/index.mjs new file mode 100644 index 00000000..9a829cb4 --- /dev/null +++ b/source/plugins/community/fortune/index.mjs @@ -0,0 +1,45 @@ +//Setup +export default async function({q, data, imports, account}, {enabled = false} = {}) { + //Plugin execution + try { + //Check if plugin is enabled and requirements are met + if ((!enabled)||(!q.fortune)) + return null + + //Load inputs + imports.metadata.plugins.fortune.inputs({data, account, q}) + + //Fortunes list + const fortunes = [ + {chance:.06, color:"#F51C6A", text:"Reply hazy"}, + {chance:.03, color:"#FD4D32", text:"Excellent Luck"}, + {chance:.16, color:"#E7890C", text:"Good Luck"}, + {chance:.24, color:"#BAC200", text:"Average Luck"}, + {chance:.16, color:"#7FEC11", text:"Bad Luck"}, + {chance:.06, color:"#43FD3B", text:"Good news will come to you by mail"}, + {chance:.06, color:"#16F174", text:"( ´_ゝ`)フーン "}, + {chance:.06, color:"#00CBB0", text:"キタ━━━━━━(゚∀゚)━━━━━━ !!!!"}, + {chance:.06, color:"#0893E1", text:"You will meet a dark handsome stranger"}, + {chance:.06, color:"#2A56FB", text:"Better not tell you now"}, + {chance:.06, color:"#6023F8", text:"Outlook good"}, + {chance:.04, color:"#9D05DA", text:"Very Bad Luck"}, + {chance:.01, color:"#D302A7", text:"Godly Luck"}, + ] + + //Result + let [fortune] = fortunes + const x = Math.random() + for (let i = 0, r = 0; i < fortunes.length; i++) { + if (x <= r) { + fortune = fortunes[i] + break + } + r += fortunes[i].chance + } + return {...fortune} + } + //Handle errors + catch (error) { + throw {error:{message:"An error occured", instance:error}} + } +} \ No newline at end of file diff --git a/source/plugins/community/fortune/metadata.yml b/source/plugins/community/fortune/metadata.yml new file mode 100644 index 00000000..0e365b72 --- /dev/null +++ b/source/plugins/community/fortune/metadata.yml @@ -0,0 +1,16 @@ +name: "🥠 Fortune" +category: community +description: This plugins displays a random fortune message +examples: + default: https://github.com/lowlighter/metrics/blob/examples/metrics.plugin.fortune.svg +authors: + - lowlighter +supports: + - user +scopes: [] +inputs: + + plugin_fortune: + description: Enable fortune plugin + type: boolean + default: no diff --git a/source/templates/classic/partials/_.json b/source/templates/classic/partials/_.json index d7d3797b..d24bb805 100644 --- a/source/templates/classic/partials/_.json +++ b/source/templates/classic/partials/_.json @@ -35,5 +35,6 @@ "screenshot", "code", "sponsors", - "poopmap" + "poopmap", + "fortune" ] diff --git a/source/templates/classic/partials/fortune.ejs b/source/templates/classic/partials/fortune.ejs new file mode 100644 index 00000000..fe1ec8ff --- /dev/null +++ b/source/templates/classic/partials/fortune.ejs @@ -0,0 +1,22 @@ +<% if (plugins.fortune) { %> +
+

+ + Fortune +

+
+
+ <% if (plugins.fortune.error) { %> +
+ + <%= plugins.fortune.error.message %> +
+ <% } else { %> +
+ Your fortune: <%= plugins.fortune.text %> +
+ <% } %> +
+
+
+<% } %> \ No newline at end of file