added reset task master command

This commit is contained in:
liyunze 2024-05-04 10:28:34 +08:00
parent 6cd20763ae
commit 36ca7ad5c0
5 changed files with 134 additions and 71 deletions

View file

@ -252,7 +252,9 @@ const configs = (function () {
leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"], leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"],
TaskMasterCommands: ["!taskmaster", "!taskchampion"], taskMasterCommands: ["!taskmaster", "!taskchampion"],
resetTaskMasterCommands: ["!resettaskmaster"],
// Help commands - please add commands in the exact format // Help commands - please add commands in the exact format
helpCommands: [ helpCommands: [
@ -372,6 +374,7 @@ const configs = (function () {
// Grouped by taskmaster-related responses // Grouped by taskmaster-related responses
taskMaster: "{user} Task Master: {taskMaster} [{taskMasterCount}]", taskMaster: "{user} Task Master: {taskMaster} [{taskMasterCount}]",
noTaskMaster: "No task master yet, {user}!", noTaskMaster: "No task master yet, {user}!",
resetTaskMaster: "Task Master has been reset, {user}!",
// Grouped by permission-related responses // Grouped by permission-related responses
notMod: "Permission denied, {user}; Mods only", notMod: "Permission denied, {user}; Mods only",

View file

@ -10,7 +10,7 @@
<script src="./auth.js"></script> <script src="./auth.js"></script>
<script src="./configs.js"></script> <script src="./configs.js"></script>
<script src="scripts/defaultConfigs.js"></script> <script src="scripts/defaultConfigs.js"></script>
<script src="scripts/functions.js"></script> <script defer src="scripts/functions.js"></script>
<script defer src="scripts/processCommand.js"></script> <script defer src="scripts/processCommand.js"></script>
<script defer src="scripts/index.js"></script> <script defer src="scripts/index.js"></script>
<script defer src="scripts/taskList.js"></script> <script defer src="scripts/taskList.js"></script>

View file

@ -1,23 +1,36 @@
const defaultConfigs = (function () { const defaultConfigs = (function () {
"use strict"; "use strict";
const StreamerUsernames = ["RythonDev"];
// settings
const settings = { const settings = {
enableLimit: false, // true or false enableLimit: false, // true or false
limit: 10, // integer limit: 10, // integer
automaticDoneIndex: false, // true or false - Automatically assume first unfinished task is complete automaticDoneIndex: false, // true or false - Automatically assume first unfinished task is complete
pointsName: "points", // string pointsName: "points", // string
pointsPerTask: 10, // integer pointsPerTask: 10, // integer
taskSeparator: [";", ",", "|"], // array of strings taskSeparator: [";", ","], // array of strings
testTasks: false, // true or false testTasks: false, // true or false
headerGoogleFont: false, // true: use google font, false: use system font headerGoogleFont: true, // true: use google font, false: use system font
taskGoogleFont: false, // true: use google font, false: use system font taskGoogleFont: true, // true: use google font, false: use system font
displayTaskCount: true, // true or false 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 = { const styles = {
// task list // task list
taskListBackgroundColor: "#000000", // hex only taskListBackgroundColor: "#000000", // hex only
@ -32,21 +45,21 @@ const defaultConfigs = (function () {
// header // header
headerHorizontalPadding: "10px", // px headerHorizontalPadding: "10px", // px
headerVerticalPadding: "20px", // px headerVerticalPadding: "10px", // px
headerBackgroundColor: "#000", // hex only headerBackgroundColor: "#fff", // hex only
headerBackgroundOpacity: 0, // 0.0 - 1.0 headerBackgroundOpacity: 1, // 0.0 - 1.0
headerBorderWidth: "0px", // px headerBorderWidth: "0px", // px
headerBorderColor: "#ffffff", // hex or name headerBorderColor: "#ffffff", // hex or name
headerBorderRadius: "3px", // px headerBorderRadius: "3px", // px
headerFontFamily: "monospace", // font name headerFontFamily: "Fredoka", // font name
headerFontSize: "2rem", // px
headerFontWeight: "bold", // normal or bold or number
headerFontColor: "#fff", // hex or name
taskCountMarginRight: "175px", // px headerFontSize: "25px", // px
headerFontWeight: "bold", // normal or bold or number
headerFontColor: "#000", // hex or name
// body // body
bodyBackgroundColor: "#fff", // hex only bodyBackgroundColor: "#fff", // hex only
@ -59,16 +72,17 @@ const defaultConfigs = (function () {
// task // task
lineHeight: 1.5, // number lineHeight: 1.5, // number
usernameFontWeight: "bold", // normal or bold or number usernameFontWeight: "bold", // normal or bold or number
usernameColor: "lime", // hex or name or "" for twitch user color usernameColor: "pink", // hex or name or "" for twitch user color
usernameFontSize: "1.5rem", // px usernameFontSize: "20px", // px
taskWidth: "100%", taskWidth: "100%",
taskBackgroundColor: "#000", // hex only taskBackgroundColor: "#000", // hex only
taskBackgroundOpacity: 0, // 0.0 - 1.0 taskBackgroundOpacity: 0, // 0.0 - 1.0
taskFontFamily: "monospace", // font name taskFontFamily: "Poppins", // font name
taskFontSize: "1.5rem", // px
taskFontSize: "20px", // px
taskFontColor: "#fff", // hex or name taskFontColor: "#fff", // hex or name
taskBorderColor: "#fff", // hex or name taskBorderColor: "#fff", // hex or name
@ -93,26 +107,10 @@ const defaultConfigs = (function () {
focusTaskVerticalPadding: "0px", // px focusTaskVerticalPadding: "0px", // px
}; };
// animation // STYLES
const animation = {
scrollSpeed: 50, // px
gapBetweenScrolls: 50, // px
titles: [
"!multitask",
"!taskhelp",
"!task",
"!edit",
"!remove",
"!done",
"!undone",
"!botcred",
"!count",
"!points",
"!boardcount",
],
};
const commands = { const commands = {
// Add task commands - please add commands in the exact format
addTaskCommands: [ addTaskCommands: [
"!taska", "!taska",
"!taskadd", "!taskadd",
@ -123,6 +121,8 @@ const defaultConfigs = (function () {
"!todo", "!todo",
"!a", "!a",
], ],
// Edit task commands - please add commands in the exact format
editTaskCommands: [ editTaskCommands: [
"!taske", "!taske",
"!taskedit", "!taskedit",
@ -131,6 +131,8 @@ const defaultConfigs = (function () {
"!edit", "!edit",
"!e", "!e",
], ],
// Delete task commands - please add commands in the exact format
deleteTaskCommands: [ deleteTaskCommands: [
"!taskdel", "!taskdel",
"!taskdelete", "!taskdelete",
@ -144,6 +146,8 @@ const defaultConfigs = (function () {
"!delete", "!delete",
"!r", "!r",
], ],
// Finish task commands - please add commands in the exact format
finishTaskCommands: [ finishTaskCommands: [
"!taskf", "!taskf",
"!taskfinish", "!taskfinish",
@ -158,6 +162,8 @@ const defaultConfigs = (function () {
"!finished", "!finished",
"!f", "!f",
], ],
// Unfinish task commands - please add commands in the exact format
unfinishTaskCommands: [ unfinishTaskCommands: [
"!tasku", "!tasku",
"!taskunfinish", "!taskunfinish",
@ -171,6 +177,7 @@ const defaultConfigs = (function () {
"!unfinished", "!unfinished",
"!u", "!u",
], ],
nextTaskCommands: [ nextTaskCommands: [
"!taskn", "!taskn",
"!tasknext", "!tasknext",
@ -179,17 +186,14 @@ const defaultConfigs = (function () {
"!next", "!next",
"!n", "!n",
], ],
// focus task commands - please add commands in the exact format
focusTaskCommands: ["!focus", "!taskfocus", "!focustask"], focusTaskCommands: ["!focus", "!taskfocus", "!focustask"],
unfocusTaskCommands: ["!unfocus", "!taskunfocus", "!unfocustask"], unfocusTaskCommands: ["!unfocus", "!taskunfocus", "!unfocustask"],
nowTaskCommands: ["!now", "!tasknow", "!nowtask"], nowTaskCommands: ["!now", "!tasknow", "!nowtask"],
helpCommands: [
"!taskh", // Check task commands - please add commands in the exact format
"!taskhelp",
"!htask",
"!helptask",
"!tasks",
"!help",
],
checkCommands: [ checkCommands: [
"!taskc", "!taskc",
"!taskcheck", "!taskcheck",
@ -199,9 +203,16 @@ const defaultConfigs = (function () {
"!check", "!check",
"!mytasks", "!mytasks",
], ],
// List tasks commands - please add commands in the exact format
listCommands: ["!taskl", "!tasklist", "!listtasks", "!list"], listCommands: ["!taskl", "!tasklist", "!listtasks", "!list"],
// Clear my done commands - please add commands in the exact format
clearMyDoneCommands: ["!clearmydone"], clearMyDoneCommands: ["!clearmydone"],
// check count commands - please add commands in the exact format
checkCountCommands: ["!taskcount", "!count", "!checkcount", "!mycount"], checkCountCommands: ["!taskcount", "!count", "!checkcount", "!mycount"],
checkAllCountCommands: [ checkAllCountCommands: [
"!taskallcount", "!taskallcount",
"!allcount", "!allcount",
@ -210,62 +221,86 @@ const defaultConfigs = (function () {
"!checkboardcount", "!checkboardcount",
"!taskboardcount", "!taskboardcount",
], ],
checkMyPointsCommands: [ checkMyPointsCommands: [
"!taskpoints", "!taskpoints",
"!points", "!points",
"!mypoints", "!mypoints",
"!checkpoints", "!checkpoints",
], ],
// sync points with count commands - please add commands in the exact format
syncCountPointsCommands: ["!syncpoints", "!synccount"], syncCountPointsCommands: ["!syncpoints", "!synccount"],
addPointsCommands: ["!addpoints", "!givepoints", "!adduserpoints"], addPointsCommands: ["!addpoints", "!givepoints", "!adduserpoints"],
reducePointsCommands: ["!reducepoints", "!takepoints"], reducePointsCommands: ["!reducepoints", "!takepoints"],
setUserPointsCommands: [ setUserPointsCommands: [
"!setuserpoints", "!setuserpoints",
"!setpoints", "!setpoints",
"!setpointsuser", "!setpointsuser",
"!setuserpoint", "!setuserpoint",
], ],
setUserTaskCountCommands: [ setUserTaskCountCommands: [
"!setusertaskcount", "!setusertaskcount",
"!settaskcount", "!settaskcount",
"!settaskcountuser", "!settaskcountuser",
"!setusertask", "!setusertask",
], ],
leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"], 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: [ adminClearNotStreamerCommands: [
"!clearnotstreamer", "!clearnotstreamer",
"!aclearnotstreamer", "!aclearnotstreamer",
"!adminclearnotstreamer", "!adminclearnotstreamer",
"!clearns", "!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: [ adminClearDoneCommands: [
"!acleardone", "!acleardone",
"!admincleardone", "!admincleardone",
"!cleardone", "!cleardone",
], ],
adminClearTasksCommands: ["!cleartasks"],
adminResetBoardCountCommands: ["!resetboardcount", "!resetallcount"],
adminResetUsersCountCommands: ["!resetuserscount"],
adminClearAllCommands: ["!clearallnoregrets"], adminClearAllCommands: ["!clearallnoregrets"],
adminClearTasksCommands: ["!cleartasks", "!clearalltasks", "!clearall"],
adminSetBoardCount: ["!setboardcount", "!setallcount"], adminSetBoardCountCommands: ["!setboardcount", "!setallcount"],
adminResetBoardCount: ["!resetboardcount", "!resetallcount"],
adminResetUsersCount: ["!resetuserscount"],
adminBackupCommands: ["!backup", "!backupdata", "!setbackup"],
adminLoadBackupCommands: [
"!loadbackup",
"!loaddata",
"!loadbackupdata",
],
additionalCommands: { additionalCommands: {
"!botcred": "!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", "{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 = { const responses = {
// Grouped by task-related responses // Responses related to task addition
// Grouped by task creation and modification responses
taskAdded: 'The task(s) "{task}" has been added, {user}!', taskAdded: 'The task(s) "{task}" has been added, {user}!',
noTaskAdded: noTaskAdded:
"Looks like you already hit the limit of incomplete tasks, {user}", "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}", "Try specifying the index of the incomplete task(s) {user}",
clearTasksExceptBroadcaster: clearTasksExceptBroadcaster:
"All tasks have been cleared except for the streamer's, {user}!", "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", adminDeleteTasks: "All of {mentioned}'s tasks have been deleted",
clearedDone: "All completed tasks have been cleared, {user}!", clearedAll: "All tasks and points have been cleared, {user}!",
clearedAll: "All tasks and counts have been cleared, {user}!",
// Grouped by task completion responses // Grouped by task completion responses
taskFinished: taskFinished:
@ -336,24 +371,28 @@ const defaultConfigs = (function () {
leaderboard: "Leaderboard: {leaderboard}", leaderboard: "Leaderboard: {leaderboard}",
setUserTaskCount: "{mentioned} now has {taskCount} tasks!", setUserTaskCount: "{mentioned} now has {taskCount} tasks!",
// backup-related responses // Grouped by taskmaster-related responses
backupStorage: "Data has been backed up, {user}!", taskMaster: "{user} Task Master: {taskMaster} [{taskMasterCount}]",
loadBackup: "Data has been loaded, {user}!", noTaskMaster: "No task master yet, {user}!",
resetTaskMaster: "Task Master has been reset, {user}!",
// Grouped by permission-related responses // Grouped by permission-related responses
notMod: "Permission denied, {user}; Mods only", notMod: "Permission denied, {user}; Mods only",
notStreamer: "Permission denied, {user}; Streamer 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/`, 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 // to edit check task command, go to
// scripts/taskList.js // scripts/taskList.js
// function checkTasks(username) // function checkTasks(username)
}; };
return { return {
StreamerUsernames,
settings, settings,
styles, styles,
animation, animation,

View file

@ -493,10 +493,10 @@ async function processCommand(user, command, message, flags, extra) {
await resetUsersCount(); await resetUsersCount();
respond(getResponse("clearedUsersCount"), params); respond(getResponse("clearedUsersCount"), params);
} else if (getCommand("TaskMasterCommands")) { } else if (getCommand("taskMasterCommands").includes(command)) {
let champion = await getTaskMasterChampion(); let champion = await getTaskMasterChampion();
if (champion === "") { if (champion === null) {
respond(getResponse("noTaskMaster"), params); respond(getResponse("noTaskMaster"), params);
return; return;
} }
@ -505,6 +505,15 @@ async function processCommand(user, command, message, flags, extra) {
params.taskMasterCount = champion.count; params.taskMasterCount = champion.count;
respond(getResponse("taskMaster"), params); 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)) { } else if (getCommand("helpCommands").includes(command)) {
respond(getResponse("help"), params); respond(getResponse("help"), params);
} else if (command === "!clearlocalstorage") { } else if (command === "!clearlocalstorage") {

View file

@ -250,9 +250,21 @@ async function getTaskMasterChampion() {
} }
} }
if (champion.count === 0) {
return null;
}
return champion; return champion;
} }
async function resetTaskMaster() {
await DBHandler.set("taskmaster", {
users: {},
startDate: new Date(),
totalCompleteCount: 0,
});
}
/** /**
* import styles from configs * import styles from configs
*/ */