From 36ca7ad5c05fe9d14059f33a48a4da7484285b7f Mon Sep 17 00:00:00 2001
From: liyunze <50455574+liyunze-coding@users.noreply.github.com>
Date: Sat, 4 May 2024 10:28:34 +0800
Subject: [PATCH] added reset task master command
---
configs.js | 5 +-
index.html | 2 +-
scripts/defaultConfigs.js | 173 +++++++++++++++++++++++---------------
scripts/processCommand.js | 13 ++-
scripts/taskList.js | 12 +++
5 files changed, 134 insertions(+), 71 deletions(-)
diff --git a/configs.js b/configs.js
index 238f930..3ed22a8 100644
--- a/configs.js
+++ b/configs.js
@@ -252,7 +252,9 @@ const configs = (function () {
leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"],
- TaskMasterCommands: ["!taskmaster", "!taskchampion"],
+ taskMasterCommands: ["!taskmaster", "!taskchampion"],
+
+ resetTaskMasterCommands: ["!resettaskmaster"],
// Help commands - please add commands in the exact format
helpCommands: [
@@ -372,6 +374,7 @@ const configs = (function () {
// Grouped by taskmaster-related responses
taskMaster: "{user} Task Master: {taskMaster} [{taskMasterCount}]",
noTaskMaster: "No task master yet, {user}!",
+ resetTaskMaster: "Task Master has been reset, {user}!",
// Grouped by permission-related responses
notMod: "Permission denied, {user}; Mods only",
diff --git a/index.html b/index.html
index b6e0ec3..7698578 100644
--- a/index.html
+++ b/index.html
@@ -10,7 +10,7 @@
-
+
diff --git a/scripts/defaultConfigs.js b/scripts/defaultConfigs.js
index 77766ed..672acb3 100644
--- a/scripts/defaultConfigs.js
+++ b/scripts/defaultConfigs.js
@@ -1,23 +1,36 @@
const defaultConfigs = (function () {
"use strict";
- const StreamerUsernames = ["RythonDev"];
-
- // settings
const settings = {
enableLimit: false, // true or false
limit: 10, // integer
automaticDoneIndex: false, // true or false - Automatically assume first unfinished task is complete
pointsName: "points", // string
pointsPerTask: 10, // integer
- taskSeparator: [";", ",", "|"], // array of strings
+ taskSeparator: [";", ","], // array of strings
testTasks: false, // true or false
- headerGoogleFont: false, // true: use google font, false: use system font
- taskGoogleFont: false, // true: use google font, false: use system font
+ headerGoogleFont: true, // true: use google font, false: use system font
+ taskGoogleFont: true, // true: use google font, false: use system font
displayTaskCount: true, // true or false
};
- // styles
+ const animation = {
+ scrollSpeed: 40, // milliseconds
+ gapBetweenScrolls: 0, // px
+ titles: [
+ "!taskhelp",
+ "!task",
+ "!edit",
+ "!remove",
+ "!done",
+ "!undone",
+ "!botcred",
+ "!count",
+ "!points",
+ "!boardcount",
+ ],
+ };
+
const styles = {
// task list
taskListBackgroundColor: "#000000", // hex only
@@ -32,21 +45,21 @@ const defaultConfigs = (function () {
// header
headerHorizontalPadding: "10px", // px
- headerVerticalPadding: "20px", // px
+ headerVerticalPadding: "10px", // px
- headerBackgroundColor: "#000", // hex only
- headerBackgroundOpacity: 0, // 0.0 - 1.0
+ headerBackgroundColor: "#fff", // hex only
+ headerBackgroundOpacity: 1, // 0.0 - 1.0
headerBorderWidth: "0px", // px
headerBorderColor: "#ffffff", // hex or name
headerBorderRadius: "3px", // px
- headerFontFamily: "monospace", // font name
- headerFontSize: "2rem", // px
- headerFontWeight: "bold", // normal or bold or number
- headerFontColor: "#fff", // hex or name
+ headerFontFamily: "Fredoka", // font name
- taskCountMarginRight: "175px", // px
+ headerFontSize: "25px", // px
+ headerFontWeight: "bold", // normal or bold or number
+
+ headerFontColor: "#000", // hex or name
// body
bodyBackgroundColor: "#fff", // hex only
@@ -59,16 +72,17 @@ const defaultConfigs = (function () {
// task
lineHeight: 1.5, // number
usernameFontWeight: "bold", // normal or bold or number
- usernameColor: "lime", // hex or name or "" for twitch user color
- usernameFontSize: "1.5rem", // px
+ usernameColor: "pink", // hex or name or "" for twitch user color
+ usernameFontSize: "20px", // px
taskWidth: "100%",
taskBackgroundColor: "#000", // hex only
taskBackgroundOpacity: 0, // 0.0 - 1.0
- taskFontFamily: "monospace", // font name
- taskFontSize: "1.5rem", // px
+ taskFontFamily: "Poppins", // font name
+
+ taskFontSize: "20px", // px
taskFontColor: "#fff", // hex or name
taskBorderColor: "#fff", // hex or name
@@ -93,26 +107,10 @@ const defaultConfigs = (function () {
focusTaskVerticalPadding: "0px", // px
};
- // animation
- const animation = {
- scrollSpeed: 50, // px
- gapBetweenScrolls: 50, // px
- titles: [
- "!multitask",
- "!taskhelp",
- "!task",
- "!edit",
- "!remove",
- "!done",
- "!undone",
- "!botcred",
- "!count",
- "!points",
- "!boardcount",
- ],
- };
+ // STYLES
const commands = {
+ // Add task commands - please add commands in the exact format
addTaskCommands: [
"!taska",
"!taskadd",
@@ -123,6 +121,8 @@ const defaultConfigs = (function () {
"!todo",
"!a",
],
+
+ // Edit task commands - please add commands in the exact format
editTaskCommands: [
"!taske",
"!taskedit",
@@ -131,6 +131,8 @@ const defaultConfigs = (function () {
"!edit",
"!e",
],
+
+ // Delete task commands - please add commands in the exact format
deleteTaskCommands: [
"!taskdel",
"!taskdelete",
@@ -144,6 +146,8 @@ const defaultConfigs = (function () {
"!delete",
"!r",
],
+
+ // Finish task commands - please add commands in the exact format
finishTaskCommands: [
"!taskf",
"!taskfinish",
@@ -158,6 +162,8 @@ const defaultConfigs = (function () {
"!finished",
"!f",
],
+
+ // Unfinish task commands - please add commands in the exact format
unfinishTaskCommands: [
"!tasku",
"!taskunfinish",
@@ -171,6 +177,7 @@ const defaultConfigs = (function () {
"!unfinished",
"!u",
],
+
nextTaskCommands: [
"!taskn",
"!tasknext",
@@ -179,17 +186,14 @@ const defaultConfigs = (function () {
"!next",
"!n",
],
+
+ // focus task commands - please add commands in the exact format
focusTaskCommands: ["!focus", "!taskfocus", "!focustask"],
unfocusTaskCommands: ["!unfocus", "!taskunfocus", "!unfocustask"],
+
nowTaskCommands: ["!now", "!tasknow", "!nowtask"],
- helpCommands: [
- "!taskh",
- "!taskhelp",
- "!htask",
- "!helptask",
- "!tasks",
- "!help",
- ],
+
+ // Check task commands - please add commands in the exact format
checkCommands: [
"!taskc",
"!taskcheck",
@@ -199,9 +203,16 @@ const defaultConfigs = (function () {
"!check",
"!mytasks",
],
+
+ // List tasks commands - please add commands in the exact format
listCommands: ["!taskl", "!tasklist", "!listtasks", "!list"],
+
+ // Clear my done commands - please add commands in the exact format
clearMyDoneCommands: ["!clearmydone"],
+
+ // check count commands - please add commands in the exact format
checkCountCommands: ["!taskcount", "!count", "!checkcount", "!mycount"],
+
checkAllCountCommands: [
"!taskallcount",
"!allcount",
@@ -210,62 +221,86 @@ const defaultConfigs = (function () {
"!checkboardcount",
"!taskboardcount",
],
+
checkMyPointsCommands: [
"!taskpoints",
"!points",
"!mypoints",
"!checkpoints",
],
+
+ // sync points with count commands - please add commands in the exact format
syncCountPointsCommands: ["!syncpoints", "!synccount"],
+
addPointsCommands: ["!addpoints", "!givepoints", "!adduserpoints"],
+
reducePointsCommands: ["!reducepoints", "!takepoints"],
+
setUserPointsCommands: [
"!setuserpoints",
"!setpoints",
"!setpointsuser",
"!setuserpoint",
],
+
setUserTaskCountCommands: [
"!setusertaskcount",
"!settaskcount",
"!settaskcountuser",
"!setusertask",
],
+
leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"],
- adminDeleteCommands: ["!taskadel", "!adel", "!adelete", "!admindelete"],
+
+ taskMasterCommands: ["!taskmaster", "!taskchampion"],
+
+ resetTaskMasterCommands: ["!resettaskmaster"],
+
+ // Help commands - please add commands in the exact format
+ helpCommands: [
+ "!taskh",
+ "!taskhelp",
+ "!htask",
+ "!helptask",
+ "!tasks",
+ "!help",
+ ],
+
+ // Admin clear all except streamer - please add commands following the exact format
adminClearNotStreamerCommands: [
"!clearnotstreamer",
"!aclearnotstreamer",
"!adminclearnotstreamer",
"!clearns",
],
+
+ // Admin delete - please add commands following the exact format
+ adminDeleteCommands: ["!taskadel", "!adel", "!adelete", "!admindelete"],
+
+ // Admin clear done - please add commands following the exact format
adminClearDoneCommands: [
"!acleardone",
"!admincleardone",
"!cleardone",
],
+
+ adminClearTasksCommands: ["!cleartasks"],
+
+ adminResetBoardCountCommands: ["!resetboardcount", "!resetallcount"],
+
+ adminResetUsersCountCommands: ["!resetuserscount"],
+
adminClearAllCommands: ["!clearallnoregrets"],
- adminClearTasksCommands: ["!cleartasks", "!clearalltasks", "!clearall"],
- adminSetBoardCount: ["!setboardcount", "!setallcount"],
- adminResetBoardCount: ["!resetboardcount", "!resetallcount"],
- adminResetUsersCount: ["!resetuserscount"],
- adminBackupCommands: ["!backup", "!backupdata", "!setbackup"],
- adminLoadBackupCommands: [
- "!loadbackup",
- "!loaddata",
- "!loadbackupdata",
- ],
+
+ adminSetBoardCountCommands: ["!setboardcount", "!setallcount"],
additionalCommands: {
"!botcred":
"{user} Ryan is the creator of this bot! You can find him on https://github.com/liyunze-coding or https://www.twitch.tv/RythonDev",
- "!multitask":
- "If you want to add the multi-task widget to your stream, you can buy it from ko-fi! https://ko-fi.com/s/94e7e8dc81",
},
};
const responses = {
- // Grouped by task-related responses
- // Grouped by task creation and modification responses
+ // Responses related to task addition
taskAdded: 'The task(s) "{task}" has been added, {user}!',
noTaskAdded:
"Looks like you already hit the limit of incomplete tasks, {user}",
@@ -291,9 +326,9 @@ const defaultConfigs = (function () {
"Try specifying the index of the incomplete task(s) {user}",
clearTasksExceptBroadcaster:
"All tasks have been cleared except for the streamer's, {user}!",
+ clearedTasks: "All tasks have been cleared, {user}!",
adminDeleteTasks: "All of {mentioned}'s tasks have been deleted",
- clearedDone: "All completed tasks have been cleared, {user}!",
- clearedAll: "All tasks and counts have been cleared, {user}!",
+ clearedAll: "All tasks and points have been cleared, {user}!",
// Grouped by task completion responses
taskFinished:
@@ -336,24 +371,28 @@ const defaultConfigs = (function () {
leaderboard: "Leaderboard: {leaderboard}",
setUserTaskCount: "{mentioned} now has {taskCount} tasks!",
- // backup-related responses
- backupStorage: "Data has been backed up, {user}!",
- loadBackup: "Data has been loaded, {user}!",
+ // Grouped by taskmaster-related responses
+ taskMaster: "{user} Task Master: {taskMaster} [{taskMasterCount}]",
+ noTaskMaster: "No task master yet, {user}!",
+ resetTaskMaster: "Task Master has been reset, {user}!",
// Grouped by permission-related responses
notMod: "Permission denied, {user}; Mods only",
notStreamer: "Permission denied, {user}; Streamer only",
- // Grouped by help-related responses
+ // Help response
help: `{user} Use the following commands to help you out - !task !edit !remove !done. For mods, you can do !adel @user. More commmands here: https://github.com/liyunze-coding/Chat-Task-Tic-Overlay/blob/main/MultiTask.md/`,
+ "chat-task-tic":
+ "Chat-Task-Tic widget is a free and open source task widget developed by @RythonDev ! https://github.com/liyunze-coding/chat-task-tic-overlay-infinity",
+ multitask:
+ "If you want to add the multi-task widget to your stream, you can buy it from ko-fi! https://ko-fi.com/s/94e7e8dc81",
// to edit check task command, go to
// scripts/taskList.js
// function checkTasks(username)
};
return {
- StreamerUsernames,
settings,
styles,
animation,
diff --git a/scripts/processCommand.js b/scripts/processCommand.js
index 5600503..062bf07 100644
--- a/scripts/processCommand.js
+++ b/scripts/processCommand.js
@@ -493,10 +493,10 @@ async function processCommand(user, command, message, flags, extra) {
await resetUsersCount();
respond(getResponse("clearedUsersCount"), params);
- } else if (getCommand("TaskMasterCommands")) {
+ } else if (getCommand("taskMasterCommands").includes(command)) {
let champion = await getTaskMasterChampion();
- if (champion === "") {
+ if (champion === null) {
respond(getResponse("noTaskMaster"), params);
return;
}
@@ -505,6 +505,15 @@ async function processCommand(user, command, message, flags, extra) {
params.taskMasterCount = champion.count;
respond(getResponse("taskMaster"), params);
+ } else if (getCommand("resetTaskMasterCommands").includes(command)) {
+ if (!isStreamer(flags)) {
+ respond(getResponse("notStreamer"), params);
+ return;
+ }
+
+ await resetTaskMaster();
+
+ respond(getResponse("resetTaskMaster"), params);
} else if (getCommand("helpCommands").includes(command)) {
respond(getResponse("help"), params);
} else if (command === "!clearlocalstorage") {
diff --git a/scripts/taskList.js b/scripts/taskList.js
index 1c6700d..df5eb5d 100644
--- a/scripts/taskList.js
+++ b/scripts/taskList.js
@@ -250,9 +250,21 @@ async function getTaskMasterChampion() {
}
}
+ if (champion.count === 0) {
+ return null;
+ }
+
return champion;
}
+async function resetTaskMaster() {
+ await DBHandler.set("taskmaster", {
+ users: {},
+ startDate: new Date(),
+ totalCompleteCount: 0,
+ });
+}
+
/**
* import styles from configs
*/