summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaindropsSys <contact@minteck.org>2023-06-23 12:49:35 +0200
committerRaindropsSys <contact@minteck.org>2023-06-23 12:49:35 +0200
commit88b3af270893d51fe6c44449156a4190a9e77112 (patch)
tree8211d0835cc78524cd96a8303612351a1e2c95d2
parent98363de507a6b0b04956db4d31c41eddae6b6a63 (diff)
downloadbutterscotch-88b3af270893d51fe6c44449156a4190a9e77112.tar.gz
butterscotch-88b3af270893d51fe6c44449156a4190a9e77112.tar.bz2
butterscotch-88b3af270893d51fe6c44449156a4190a9e77112.zip
Updated 2 files (automated)
-rw-r--r--commands/evening.js56
-rw-r--r--help/evening.json2
2 files changed, 46 insertions, 12 deletions
diff --git a/commands/evening.js b/commands/evening.js
index 3503771..e7d7dd8 100644
--- a/commands/evening.js
+++ b/commands/evening.js
@@ -1,4 +1,5 @@
const axios = require("axios");
+const {isNumber} = require("matrix-js-sdk/lib/utils");
module.exports = (parameter, wrapper) => {
if (wrapper.sender !== "@cloudburst:equestria.dev" && wrapper.sender !== "@raindrops:equestria.dev" && wrapper.sender !== "186730180872634368" && wrapper.sender !== "493845599469174794") {
@@ -6,6 +7,12 @@ module.exports = (parameter, wrapper) => {
return;
}
+ let selectedDay;
+
+ if (parameter && !isNaN(parseInt(parameter)) && parameter > -1 && parameter < 7) {
+ selectedDay = parseInt(parameter);
+ }
+
/*
[ - Will be 'null' if the day has been ignored
@@ -27,23 +34,50 @@ module.exports = (parameter, wrapper) => {
}
}).then(res => {
let data = res.data;
+ let text = "";
- let text = "🌙 Here is what is scheduled for the next nights:\n\n### Tonight\n";
+ function appendDay(day, name, mini) {
+ if (!mini) text += "\n* <u>" + name + ":</u> ";
- if (data[0]) {
- text += "* **" + data[0][0].join("** and **") + "**\n";
- text += "* **" + data[0][1].join("** and **") + "**";
- } else {
- text += "*Tonight has been marked as ignored*";
+ if (data[day]) {
+ let locked = false;
+
+ if (data[day][0].map(i => i.endsWith("*")).includes(true)) {
+ locked = true;
+ text += " **" + data[day][0].map(i => i.substring(0, i.length - 1)).join("** and **") + "** with";
+ } else {
+ text += " **" + data[day][0].join("** and **") + "** with";
+ }
+
+ if (data[day][1].map(i => i.endsWith("*")).includes(true)) {
+ locked = true;
+ text += " **" + data[day][1].map(i => i.substring(0, i.length - 1)).join("** and **") + "**";
+ } else {
+ text += " **" + data[day][1].join("** and **") + "**";
+ }
+
+ if (locked) {
+ text += " *(locked)*";
+ }
+ } else {
+ text += "*(marked as ignored)*";
+ }
}
- text += "\n\n### Tomorrow\n";
+ if (selectedDay) {
+ text = "🌙 Here is what is scheduled for " + (selectedDay === 0 ? "tonight" : (selectedDay === 1 ? "tomorrow" : "the " + new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * selectedDay))))) + ":";
- if (data[1]) {
- text += "* **" + data[1][0].join("** and **") + "**\n";
- text += "* **" + data[1][1].join("** and **") + "**";
+ appendDay(selectedDay, "", true);
} else {
- text += "*Tomorrow has been marked as ignored*";
+ text = "🌙 Here is what is scheduled for the next nights:\n";
+
+ appendDay(0, "Tonight");
+ appendDay(1, "Tomorrow");
+ appendDay(2, new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * 2))));
+ appendDay(3, new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * 3))));
+ appendDay(4, new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * 4))));
+ appendDay(5, new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * 5))));
+ appendDay(6, new Intl.DateTimeFormat('en-IE', { weekday: "long", day: "numeric" }).format(new Date(new Date().getTime() + (86400000 * 6))));
}
text += "\n\n[[View on Cold Haze](https://ponies.equestria.horse/-/evening)]";
diff --git a/help/evening.json b/help/evening.json
index 2604516..e35d469 100644
--- a/help/evening.json
+++ b/help/evening.json
@@ -1,6 +1,6 @@
{
"description": "Shows a summary of the evening schedule.",
- "parameters": "",
+ "parameters": " [day]",
"aliases": [ "schedule", "planner", "f", "plan", "e", "evening" ],
"exempt": false
} \ No newline at end of file