timestamps every 15 minutes
This commit is contained in:
parent
3017a23be7
commit
3a8d099e9e
2 changed files with 53 additions and 1 deletions
50
src/index.js
50
src/index.js
|
@ -152,3 +152,53 @@ client.connect();
|
||||||
|
|
||||||
console.log("COMcord (c)left 2022");
|
console.log("COMcord (c)left 2022");
|
||||||
console.log("Type 'h' for Commands");
|
console.log("Type 'h' for Commands");
|
||||||
|
|
||||||
|
const dateObj = new Date();
|
||||||
|
let sentTime = false;
|
||||||
|
|
||||||
|
const weekdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
|
||||||
|
const months = [
|
||||||
|
"Jan",
|
||||||
|
"Feb",
|
||||||
|
"Mar",
|
||||||
|
"Apr",
|
||||||
|
"May",
|
||||||
|
"Jun",
|
||||||
|
"Jul",
|
||||||
|
"Aug",
|
||||||
|
"Sep",
|
||||||
|
"Oct",
|
||||||
|
"Nov",
|
||||||
|
"Dec",
|
||||||
|
];
|
||||||
|
|
||||||
|
setInterval(function () {
|
||||||
|
dateObj.setTime(Date.now());
|
||||||
|
|
||||||
|
const hour = dateObj.getUTCHours(),
|
||||||
|
minutes = dateObj.getUTCMinutes(),
|
||||||
|
seconds = dateObj.getUTCSeconds(),
|
||||||
|
day = dateObj.getUTCDate(),
|
||||||
|
month = dateObj.getUTCMonth(),
|
||||||
|
year = dateObj.getUTCFullYear(),
|
||||||
|
weekDay = dateObj.getUTCDay();
|
||||||
|
|
||||||
|
const timeString = `[${weekdays[weekDay]} ${day
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}-${months[month]}-${year
|
||||||
|
.toString()
|
||||||
|
.substring(2, 4)} ${hour.toString().padStart(2, "0")}:${minutes
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}:${seconds.toString().padStart(2, "0")}]`;
|
||||||
|
|
||||||
|
if (minutes % 15 == 0 && seconds < 2 && !sentTime) {
|
||||||
|
if (comcord.state.inPrompt == true) {
|
||||||
|
comcord.state.messageQueue.push({time: true, content: timeString});
|
||||||
|
} else {
|
||||||
|
console.log(timeString);
|
||||||
|
}
|
||||||
|
sentTime = true;
|
||||||
|
} else if (seconds > 2 && sentTime) {
|
||||||
|
sentTime = false;
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
|
|
@ -87,7 +87,9 @@ function processMessage({
|
||||||
|
|
||||||
function processQueue() {
|
function processQueue() {
|
||||||
for (const msg of comcord.state.messageQueue) {
|
for (const msg of comcord.state.messageQueue) {
|
||||||
if (msg.content.indexOf("\n") > -1) {
|
if (msg.time) {
|
||||||
|
console.log(msg.content);
|
||||||
|
} else if (msg.content.indexOf("\n") > -1) {
|
||||||
const lines = msg.content.split("\n");
|
const lines = msg.content.split("\n");
|
||||||
for (const index in lines) {
|
for (const index in lines) {
|
||||||
const line = lines[index];
|
const line = lines[index];
|
||||||
|
|
Loading…
Reference in a new issue