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"],
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",

View file

@ -10,7 +10,7 @@
<script src="./auth.js"></script>
<script src="./configs.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/index.js"></script>
<script defer src="scripts/taskList.js"></script>

View file

@ -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,

View file

@ -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") {

View file

@ -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
*/