BETA changed configs format, nowTask, score display

This commit is contained in:
liyunze 2024-01-17 12:59:58 +08:00
parent 8b7d1f8660
commit 4631b1f6a3
4 changed files with 788 additions and 559 deletions

View file

@ -1,100 +1,117 @@
const configs = (function () { const configs = (function () {
"use strict"; "use strict";
// settings const settings = {
const enableLimit = false; // true or false enableLimit: false, // true or false
const limit = 10; // integer limit: 10, // integer
const automaticDoneIndex = true; // true or false - Automatically assume first unfinished task is complete automaticDoneIndex: true, // true or false - Automatically assume first unfinished task is complete
const pointsName = "points"; // string pointsName: "points", // string
const pointsPerTask = 10; // integer pointsPerTask: 10, // integer
const taskSeparator = [";", ","]; // array of strings taskSeparator: [";", ","], // array of strings
testTasks: false, // true or false
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
};
// SETTING THIS 'TRUE' WILL RESET EXISTING TASKS const animation = {
const testTasks = false; // true or false scrollSpeed: 40, // milliseconds
gapBetweenScrolls: 0, // px
titles: [
"!taskhelp",
"!task",
"!edit",
"!remove",
"!done",
"!undone",
"!botcred",
"!count",
"!points",
"!boardcount",
],
};
// animation const styles = {
const scrollSpeed = 40; // milliseconds
const gapBetweenScrolls = 0; // px
// STYLES
// task list // task list
const taskListBackgroundColor = "#000000"; // hex only taskListBackgroundColor: "#000000", // hex only
const taskListBackgroundOpacity = 0; // 0.0 - 1.0 taskListBackgroundOpacity: 0, // 0.0 - 1.0
const taskListBorderWidth = "0px"; // px taskListBorderWidth: "0px", // px
const taskListBorderColor = "#ffffff"; // hex or name taskListBorderColor: "#ffffff", // hex or name
const taskListBorderRadius = "0px"; // px taskListBorderRadius: "0px", // px
const taskListHorizontalPadding = "0px"; // px taskListHorizontalPadding: "0px", // px
const taskListVerticalPadding = "0px"; // px taskListVerticalPadding: "0px", // px
// header // header
const headerHorizontalPadding = "10px"; // px headerHorizontalPadding: "10px", // px
const headerVerticalPadding = "10px"; // px headerVerticalPadding: "10px", // px
const headerBackgroundColor = "#fff"; // hex only headerBackgroundColor: "#fff", // hex only
const headerBackgroundOpacity = 1; // 0.0 - 1.0 headerBackgroundOpacity: 1, // 0.0 - 1.0
const headerBorderWidth = "0px"; // px headerBorderWidth: "0px", // px
const headerBorderColor = "#ffffff"; // hex or name headerBorderColor: "#ffffff", // hex or name
const headerBorderRadius = "3px"; // px headerBorderRadius: "3px", // px
const headerFontFamily = "Fredoka"; // font name headerFontFamily: "Fredoka", // font name
const headerGoogleFont = true; // true: use google font, false: use system font
const headerFontSize = "25px"; // px headerFontSize: "25px", // px
const headerFontWeight = "bold"; // normal or bold or number headerFontWeight: "bold", // normal or bold or number
const headerFontColor = "#000"; // hex or name headerFontColor: "#000", // hex or name
// body // body
const bodyBackgroundColor = "#fff"; // hex only bodyBackgroundColor: "#fff", // hex only
const bodyBackgroundOpacity = 0; // 0.0 - 1.0 bodyBackgroundOpacity: 0, // 0.0 - 1.0
const bodyBorderWidth = "0px"; // px bodyBorderWidth: "0px", // px
const bodyBorderColor = "#fff"; // hex or name bodyBorderColor: "#fff", // hex or name
const bodyBorderRadius = "5px"; // px bodyBorderRadius: "5px", // px
// task // task
const lineHeight = 1.5; // number lineHeight: 1.5, // number
const usernameFontWeight = "bold"; // normal or bold or number usernameFontWeight: "bold", // normal or bold or number
const usernameColor = "pink"; // hex or name or "" for twitch user color usernameColor: "pink", // hex or name or "" for twitch user color
const usernameFontSize = "20px"; // px usernameFontSize: "20px", // px
const taskWidth = "100%"; taskWidth: "100%",
const taskBackgroundColor = "#000"; // hex only taskBackgroundColor: "#000", // hex only
const taskBackgroundOpacity = 0; // 0.0 - 1.0 taskBackgroundOpacity: 0, // 0.0 - 1.0
const taskFontFamily = "Poppins"; // font name taskFontFamily: "Poppins", // font name
const taskGoogleFont = true; // true: use google font, false: use system font
const taskFontSize = "20px"; // px taskFontSize: "20px", // px
const taskFontColor = "#fff"; // hex or name taskFontColor: "#fff", // hex or name
const taskBorderColor = "#fff"; // hex or name taskBorderColor: "#fff", // hex or name
const taskBorderWidth = "0px"; // px taskBorderWidth: "0px", // px
const taskBorderRadius = "10px"; // px taskBorderRadius: "10px", // px
const taskMarginBottom = "10px"; // px taskMarginBottom: "10px", // px
const taskHorizontalPadding = "20px"; // px taskHorizontalPadding: "20px", // px
const taskVerticalPadding = "10px"; // px taskVerticalPadding: "10px", // px
// done task // done task
const doneTaskFontColor = "#bbb"; // hex or name doneTaskFontColor: "#bbb", // hex or name
// focus task // focus task
const focusTaskBackgroundColor = "#fff"; // hex only focusTaskBackgroundColor: "#fff", // hex only
const focusTaskBackgroundOpacity = 1; // 0.0 - 1.0 focusTaskBackgroundOpacity: 1, // 0.0 - 1.0
const focusTaskBorderRadius = "5px"; // px focusTaskBorderRadius: "5px", // px
const focusTaskFontColor = "#000"; // hex or name focusTaskFontColor: "#000", // hex or name
const focusTaskHorizontalPadding = "7px"; // px focusTaskHorizontalPadding: "7px", // px
const focusTaskVerticalPadding = "0px"; // px focusTaskVerticalPadding: "0px", // px
};
// STYLES
const commands = {
// Add task commands - please add commands in the exact format // Add task commands - please add commands in the exact format
const addTaskCommands = [ addTaskCommands: [
"!taska", "!taska",
"!taskadd", "!taskadd",
"!atask", "!atask",
@ -103,20 +120,20 @@ const configs = (function () {
"!add", "!add",
"!todo", "!todo",
"!a", "!a",
]; ],
// Edit task commands - please add commands in the exact format // Edit task commands - please add commands in the exact format
const editTaskCommands = [ editTaskCommands: [
"!taske", "!taske",
"!taskedit", "!taskedit",
"!etask", "!etask",
"!edittask", "!edittask",
"!edit", "!edit",
"!e", "!e",
]; ],
// Delete task commands - please add commands in the exact format // Delete task commands - please add commands in the exact format
const deleteTaskCommands = [ deleteTaskCommands: [
"!taskdel", "!taskdel",
"!taskdelete", "!taskdelete",
"!deltask", "!deltask",
@ -128,10 +145,10 @@ const configs = (function () {
"!remove", "!remove",
"!delete", "!delete",
"!r", "!r",
]; ],
// Finish task commands - please add commands in the exact format // Finish task commands - please add commands in the exact format
const finishTaskCommands = [ finishTaskCommands: [
"!taskf", "!taskf",
"!taskfinish", "!taskfinish",
"!ftask", "!ftask",
@ -144,10 +161,10 @@ const configs = (function () {
"!done", "!done",
"!finished", "!finished",
"!f", "!f",
]; ],
// Unfinish task commands - please add commands in the exact format // Unfinish task commands - please add commands in the exact format
const unfinishTaskCommands = [ unfinishTaskCommands: [
"!tasku", "!tasku",
"!taskunfinish", "!taskunfinish",
"!utask", "!utask",
@ -159,15 +176,25 @@ const configs = (function () {
"!unfinish", "!unfinish",
"!unfinished", "!unfinished",
"!u", "!u",
]; ],
nextTaskCommands: [
"!taskn",
"!tasknext",
"!ntask",
"!nexttask",
"!next",
"!n",
],
// focus task commands - please add commands in the exact format // focus task commands - please add commands in the exact format
const focusTaskCommands = ["!focus", "!taskfocus", "!focustask"]; focusTaskCommands: ["!focus", "!taskfocus", "!focustask"],
unfocusTaskCommands: ["!unfocus", "!taskunfocus", "!unfocustask"],
const unfocusTaskCommands = ["!unfocus", "!taskunfocus", "!unfocustask"]; nowTaskCommands: ["!now", "!tasknow", "!nowtask"],
// Check task commands - please add commands in the exact format // Check task commands - please add commands in the exact format
const checkCommands = [ checkCommands: [
"!taskc", "!taskc",
"!taskcheck", "!taskcheck",
"!ctask", "!ctask",
@ -175,364 +202,185 @@ const configs = (function () {
"!mytask", "!mytask",
"!check", "!check",
"!mytasks", "!mytasks",
]; ],
// List tasks commands - please add commands in the exact format // List tasks commands - please add commands in the exact format
const listCommands = ["!taskl", "!tasklist", "!listtasks", "!list"]; listCommands: ["!taskl", "!tasklist", "!listtasks", "!list"],
// Clear my done commands - please add commands in the exact format // Clear my done commands - please add commands in the exact format
const clearMyDoneCommands = ["!clearmydone"]; clearMyDoneCommands: ["!clearmydone"],
// check count commands - please add commands in the exact format // check count commands - please add commands in the exact format
const checkCountCommands = [ checkCountCommands: ["!taskcount", "!count", "!checkcount", "!mycount"],
"!taskcount",
"!count",
"!checkcount",
"!mycount",
];
const checkAllCountCommands = [ checkAllCountCommands: [
"!taskallcount", "!taskallcount",
"!allcount", "!allcount",
"!checkallcount", "!checkallcount",
"!boardcount", "!boardcount",
"!checkboardcount", "!checkboardcount",
"!taskboardcount", "!taskboardcount",
]; ],
const checkMyPointsCommands = [ checkMyPointsCommands: [
"!taskpoints", "!taskpoints",
"!points", "!points",
"!mypoints", "!mypoints",
"!checkpoints", "!checkpoints",
]; ],
// sync points with count commands - please add commands in the exact format // sync points with count commands - please add commands in the exact format
const syncCountPointsCommands = ["!syncpoints", "!synccount"]; syncCountPointsCommands: ["!syncpoints", "!synccount"],
const addPointsCommands = ["!addpoints", "!givepoints", "!adduserpoints"]; addPointsCommands: ["!addpoints", "!givepoints", "!adduserpoints"],
const reducePointsCommands = ["!reducepoints", "!takepoints"]; reducePointsCommands: ["!reducepoints", "!takepoints"],
const setUserPointsCommands = [ setUserPointsCommands: [
"!setuserpoints", "!setuserpoints",
"!setpoints", "!setpoints",
"!setpointsuser", "!setpointsuser",
"!setuserpoint", "!setuserpoint",
]; ],
const setUserTaskCountCommands = [ setUserTaskCountCommands: [
"!setusertaskcount", "!setusertaskcount",
"!settaskcount", "!settaskcount",
"!settaskcountuser", "!settaskcountuser",
"!setusertask", "!setusertask",
]; ],
const leaderboardCommands = ["!leaderboard", "!lb", "!top", "!toppoints"]; leaderboardCommands: ["!leaderboard", "!lb", "!top", "!toppoints"],
// Help commands - please add commands in the exact format // Help commands - please add commands in the exact format
const helpCommands = [ helpCommands: [
"!taskh", "!taskh",
"!taskhelp", "!taskhelp",
"!htask", "!htask",
"!helptask", "!helptask",
"!tasks", "!tasks",
"!help", "!help",
]; ],
// Admin clear all except streamer - please add commands following the exact format // Admin clear all except streamer - please add commands following the exact format
const adminClearNotStreamerCommands = [ adminClearNotStreamerCommands: [
"!clearnotstreamer", "!clearnotstreamer",
"!aclearnotstreamer", "!aclearnotstreamer",
"!adminclearnotstreamer", "!adminclearnotstreamer",
"!clearns", "!clearns",
]; ],
// Admin delete - please add commands following the exact format // Admin delete - please add commands following the exact format
const adminDeleteCommands = [ adminDeleteCommands: ["!taskadel", "!adel", "!adelete", "!admindelete"],
"!taskadel",
"!adel",
"!adelete",
"!admindelete",
];
// Admin clear done - please add commands following the exact format // Admin clear done - please add commands following the exact format
const adminClearDoneCommands = [ adminClearDoneCommands: [
"!acleardone", "!acleardone",
"!admincleardone", "!admincleardone",
"!cleardone", "!cleardone",
]; ],
const adminClearTasksCommands = ["!cleartasks"]; adminClearTasksCommands: ["!cleartasks"],
const adminResetBoardCount = ["!resetboardcount", "!resetallcount"]; adminResetBoardCount: ["!resetboardcount", "!resetallcount"],
const adminResetUsersCount = ["!resetuserscount"]; adminResetUsersCount: ["!resetuserscount"],
const adminClearAllCommands = [ adminClearAllCommands: [
"!clearall", "!clearall",
"!allclear", "!allclear",
"!adminclearall", "!adminclearall",
"!adminallclear", "!adminallclear",
"!aclearall", "!aclearall",
"!aclear", "!aclear",
]; ],
const adminSetBoardCount = ["!setboardcount", "!setallcount"]; adminSetBoardCount: ["!setboardcount", "!setallcount"],
additionalCommands: {
// Responses related to task addition
const taskAdded = 'The task(s) "{task}" has been added, {user}!';
const noTaskAdded =
"Looks like you already hit the limit of incomplete tasks, {user}";
const noTaskContent = "Try using !task the-task-you-are-working-on {user}";
const duplicateTask =
"Looks like you already have the task '{message}' up there {user}!";
// Responses related to task deletion
const taskDeleted =
'Task(s) "{task}" has been deleted successfully, {user}';
const specifyTaskIndex =
"Try specifying the index of the incomplete task(s) {user}";
const clearTasksExceptBroadcaster =
"All tasks have been cleared except for the streamer's, {user}!";
const adminDeleteTasks = "All of {mentioned}'s tasks have been deleted";
// Responses related to task completion
const taskFinished =
'Good job on finishing the task(s) "{task}", {user}! You have earned {pointCount} {pointName} and completed {doneCount} task(s) so far!';
const allTasksFinished =
"Good job on finishing all your tasks, {user}! You have completed {doneCount} task(s) so far!";
const taskUnfinished =
'Task(s) "{task}" has been unmarked as done, {user}!';
const taskAlreadyFinished =
"Looks like you already finished that task {user}";
// Responses related to task editing
const taskEdited =
'Task "{originalTask}" has been edited to "{task}" successfully, {user}';
const noTaskEdit = "Try doing !edit [index] [new task] {user}";
// Responses related to task focus
const taskFocused = 'Task "{task}" has been focused, {user}!';
const clearFocused = "Task has been unfocused, {user}!";
const noFocusedTask = "Looks like you don't have a focused task {user}!";
const alreadyFocusedTask =
"Looks like you already have that task set to focus {user}!";
const onlyOneFocus = "You can only focus one task at a time {user}!";
const specifyFocusTask =
"Try specifying an incomplete task to focus {user}!";
// Responses related to task existence
const noTask = "Looks like you don't have a task up there {user}";
const noTaskA = "Looks like there is no task from that user there {user}";
// Responses related to viewing counts / points
const checkMyPoints = "You have {pointCount} {pointName}, {user}!";
const checkUserPoints =
"{mentioned} has {pointCount} {pointName}, {user}!";
const checkYourCount =
"You have completed {doneCount} task(s) so far, {user}!";
const checkUserCount =
"{mentioned} has completed {doneCount} task(s) so far, {user}!";
const checkAllCount =
"Everyone has completed {doneCount} task(s) so far, {user}!";
const noCountAll = "Looks like no one has completed a task yet {user}";
const leaderboard = "Leaderboard: {leaderboard}";
// Responses related to modifying points
const syncCountPoints = "Points have been synced with count, {user}!";
const addPoints = "{mentioned} has been given {pointCount} {pointName}!";
const reducePoints = "{mentioned} has lost {pointCount} {pointName}!";
const setUserPoints = "{mentioned} now has {pointCount} {pointName}!";
const setUserTaskCount = "{mentioned} now has {taskCount} tasks!";
const specifyPoints = "Try specifying a number of points {user}";
// Responses related to permissions
const notMod = "Permission denied, {user}; Mods only";
const notStreamer = "Permission denied, {user}; Streamer only";
// Responses related to clearing tasks / counts
const clearedAll = "All tasks and counts have been cleared!";
const clearedTasks = "All tasks have been cleared!";
const clearedDone = "All completed tasks have been cleared!";
const clearedMyDone = "All your completed tasks have been cleared!";
const clearedBoardCount = "The board count has been reset!";
const clearedUsersCount = "The users count has been reset!";
const setBoardCount = "The board count has been set to {count}!";
const specifyUser = "Try specifying a user to delete their tasks {user}";
const invalidNumber = "Try specifying a valid number {user}";
// Help response
const 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/`;
// to edit check task command, go to
// scripts/taskList.js
// function checkTasks(username)
const 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",
}; },
const titles = [
"!taskhelp",
"!task",
"!edit",
"!remove",
"!done",
"!undone",
"!botcred",
"!count",
"!points",
"!boardcount",
];
const settings = {
enableLimit,
limit,
automaticDoneIndex,
pointsName,
pointsPerTask,
taskSeparator,
headerGoogleFont,
taskGoogleFont,
testTasks,
};
const styles = {
taskListBackgroundColor,
taskListBackgroundOpacity,
taskListBorderWidth,
taskListBorderColor,
taskListBorderRadius,
taskListHorizontalPadding,
taskListVerticalPadding,
headerHorizontalPadding,
headerVerticalPadding,
headerBackgroundColor,
headerBackgroundOpacity,
headerBorderWidth,
headerBorderColor,
headerBorderRadius,
headerFontSize,
headerFontWeight,
headerFontFamily,
headerFontColor,
bodyBackgroundColor,
bodyBackgroundOpacity,
bodyBorderWidth,
bodyBorderColor,
bodyBorderRadius,
taskWidth,
lineHeight,
usernameFontWeight,
usernameColor,
usernameFontSize,
doneTaskFontColor,
taskBackgroundColor,
taskBackgroundOpacity,
taskFontFamily,
taskFontSize,
taskFontColor,
taskBorderColor,
taskBorderWidth,
taskBorderRadius,
taskMarginBottom,
taskHorizontalPadding,
taskVerticalPadding,
focusTaskBackgroundColor,
focusTaskBackgroundOpacity,
focusTaskFontColor,
focusTaskHorizontalPadding,
focusTaskVerticalPadding,
focusTaskBorderRadius,
};
const animation = {
scrollSpeed,
gapBetweenScrolls,
titles,
};
const commands = {
addTaskCommands,
editTaskCommands,
deleteTaskCommands,
finishTaskCommands,
unfinishTaskCommands,
focusTaskCommands,
unfocusTaskCommands,
helpCommands,
checkCommands,
listCommands,
clearMyDoneCommands,
checkCountCommands,
checkAllCountCommands,
checkMyPointsCommands,
syncCountPointsCommands,
addPointsCommands,
reducePointsCommands,
setUserPointsCommands,
setUserTaskCountCommands,
leaderboardCommands,
adminDeleteCommands,
adminClearNotStreamerCommands,
adminClearDoneCommands,
adminClearAllCommands,
adminClearTasksCommands,
adminSetBoardCount,
adminResetBoardCount,
adminResetUsersCount,
additionalCommands,
}; };
const responses = { const responses = {
taskAdded, // Responses related to task addition
noTaskAdded, taskAdded: 'The task(s) "{task}" has been added, {user}!',
noTaskContent, noTaskAdded:
taskDeleted, "Looks like you already hit the limit of incomplete tasks, {user}",
specifyTaskIndex, noTaskContent: "Try using !task the-task-you-are-working-on {user}",
duplicateTask, duplicateTask:
taskFinished, "Looks like you already have the task '{message}' up there {user}!",
allTasksFinished, taskEdited:
taskUnfinished, 'Task "{originalTask}" has been edited to "{task}" successfully, {user}',
taskAlreadyFinished, noTaskEdit: "Try doing !edit [index] [new task] {user}",
taskEdited, nowTask: 'Task "{task}" is now the task you are working on, {user}!',
noTaskEdit,
clearFocused, // Grouped by task progression responses
noFocusedTask, taskNext:
alreadyFocusedTask, "Good job on finishing the task '{oldTask}'! Now moving onto '{newTask}', {user}!",
onlyOneFocus, nextNoContent: "Try using !next the-task-you-want-to-do-next {user}",
specifyFocusTask, taskNextFailed:
taskFocused, "Unable to perform command with multiple incomplete tasks, {user}!",
noTask,
noTaskA, // Grouped by task deletion responses
checkMyPoints, clearedMyDone: "All of your completed tasks have been cleared, {user}!",
checkUserPoints, taskDeleted: 'Task(s) "{task}" has been deleted successfully, {user}',
checkYourCount, specifyTaskIndex:
checkUserCount, "Try specifying the index of the incomplete task(s) {user}",
checkAllCount, clearTasksExceptBroadcaster:
noCountAll, "All tasks have been cleared except for the streamer's, {user}!",
leaderboard, adminDeleteTasks: "All of {mentioned}'s tasks have been deleted",
syncCountPoints,
addPoints, // Grouped by task completion responses
reducePoints, taskFinished:
setUserPoints, 'Good job on finishing the task(s) "{task}", {user}! You have earned {pointCount} {pointName} and completed {doneCount} task(s) so far!',
setUserTaskCount, allTasksFinished:
specifyPoints, "Good job on finishing all your tasks, {user}! You have completed {doneCount} task(s) so far!",
notMod, taskUnfinished: 'Task(s) "{task}" has been unmarked as done, {user}!',
notStreamer, taskAlreadyFinished: "Looks like you already finished that task {user}",
help,
clearTasksExceptBroadcaster, // Grouped by task focus responses
adminDeleteTasks, clearFocused: "Task has been unfocused, {user}!",
clearedMyDone, noFocusedTask: "Looks like you don't have a focused task {user}!",
clearedBoardCount, alreadyFocusedTask:
clearedUsersCount, "Looks like you already have that task set to focus {user}!",
clearedAll, onlyOneFocus: "You can only focus one task at a time {user}!",
clearedTasks, specifyFocusTask: "Try specifying an incomplete task to focus {user}!",
clearedDone, taskFocused: 'Task "{task}" has been focused, {user}!',
setBoardCount,
specifyUser, // Grouped by task existence responses
invalidNumber, noTask: "Looks like you don't have a task up there {user}",
noTaskA: "Looks like there is no task from that user there {user}",
// Grouped by point-related responses
checkMyPoints: "You have {pointCount} {pointName}, {user}!",
checkUserPoints: "{mentioned} has {pointCount} {pointName}, {user}!",
syncCountPoints: "Points have been synced with count, {user}!",
addPoints: "{mentioned} has been given {pointCount} {pointName}!",
reducePoints: "{mentioned} has lost {pointCount} {pointName}!",
setUserPoints: "{mentioned} now has {pointCount} {pointName}!",
specifyPoints: "Try specifying a number of points {user}",
// Grouped by count-related responses
checkYourCount:
"You have completed {doneCount} task(s) so far, {user}!",
checkUserCount:
"{mentioned} has completed {doneCount} task(s) so far, {user}!",
checkAllCount:
"Everyone has completed {doneCount} task(s) so far, {user}!",
noCountAll: "Looks like no one has completed a task yet {user}",
leaderboard: "Leaderboard: {leaderboard}",
setUserTaskCount: "{mentioned} now has {taskCount} tasks!",
// Grouped by permission-related responses
notMod: "Permission denied, {user}; Mods only",
notStreamer: "Permission denied, {user}; Streamer only",
// 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/`,
// to edit check task command, go to
// scripts/taskList.js
// function checkTasks(username)
}; };
return { return {

View file

@ -1,5 +0,0 @@
https://id.twitch.tv/oauth2/authorize
?client_id=CLIENT_ID_HERE
&redirect_uri=http://localhost
&response_type=token
&scope=channel:moderate+chat:edit+chat:read+channel:manage:broadcast+user:edit:broadcast+channel:read:redemptions+user:read:email

View file

@ -18,9 +18,7 @@ function isStreamer(flags) {
return flags.broadcaster; return flags.broadcaster;
} }
ComfyJS.onCommand = (user, command, message, flags, extra) => { function processCommand(user, command, message, flags, extra) {
command = `!${command.toLowerCase()}`;
params = { params = {
user: user, user: user,
message: message, message: message,
@ -131,6 +129,35 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
} }
respond(unfinishedResponse, params); respond(unfinishedResponse, params);
} else if (commands.nextTaskCommands.includes(command)) {
let nextRequest = nextTask(user, message);
if (nextRequest.status !== 200) {
respond(nextRequest.body.error, params);
return;
}
// task next
let nextResponse = responses.taskNext;
params.oldTask = nextRequest.body.oldTask;
params.newTask = nextRequest.body.newTask;
respond(nextResponse, params);
} else if (commands.nowTaskCommands.includes(command)) {
let nowRequest = nowTask(user, extra.userColor, message);
if (nowRequest.status !== 200) {
respond(nowRequest.body.error, params);
return;
}
// task now
let nowResponse = responses.nowTask;
params.task = nowRequest.body.task;
respond(nowResponse, params);
} else if (commands.focusTaskCommands.includes(command)) { } else if (commands.focusTaskCommands.includes(command)) {
let focusRequest = focusTask(user, message); let focusRequest = focusTask(user, message);
@ -166,7 +193,7 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
return; return;
} }
return ComfyJS.Say(checkRequest.body.reply); return respond(checkRequest.body.reply, params);
} else { } else {
let mentioned = message.replace("@", ""); let mentioned = message.replace("@", "");
let checkRequest = checkTasks(mentioned); let checkRequest = checkTasks(mentioned);
@ -177,7 +204,7 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
return; return;
} }
return ComfyJS.Say(checkRequest.body.reply); return respond(checkRequest.body.reply, params);
} }
} else if (commands.adminDeleteCommands.includes(command)) { } else if (commands.adminDeleteCommands.includes(command)) {
if (!isMod(flags)) { if (!isMod(flags)) {
@ -224,7 +251,7 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
} else if (commands.clearMyDoneCommands.includes(command)) { } else if (commands.clearMyDoneCommands.includes(command)) {
let clearOwnDoneResponse = clearOwnDoneTasks(user); let clearOwnDoneResponse = clearOwnDoneTasks(user);
if (clearOwnDoneResponse.status === 0) { if (clearOwnDoneResponse.status !== 200) {
// no tasks // no tasks
respond(responses.noTask, params); respond(responses.noTask, params);
return; return;
@ -491,6 +518,12 @@ ComfyJS.onCommand = (user, command, message, flags, extra) => {
} else { } else {
// command not found // command not found
} }
}
ComfyJS.onCommand = (user, command, message, flags, extra) => {
command = `!${command.toLowerCase()}`;
processCommand(user, command, message, flags, extra);
}; };
ComfyJS.Init(auth.username, `oauth:${auth.oauth}`, [auth.channel]); ComfyJS.Init(auth.username, `oauth:${auth.oauth}`, [auth.channel]);

View file

@ -125,6 +125,10 @@ function importStyles() {
); );
}); });
if (!settings.displayTaskCount) {
document.querySelector(".task-count").style.display = "none";
}
let currentTitle = 0; let currentTitle = 0;
// interval the task title // interval the task title
setInterval(async () => { setInterval(async () => {
@ -268,6 +272,7 @@ function addDoneCount(username, value) {
counts.users[username.toLowerCase()].completeCount += value; counts.users[username.toLowerCase()].completeCount += value;
counts.totalCompleteCount += value; counts.totalCompleteCount += value;
taskListMemory.doneTaskCount += value;
// check if user has points // check if user has points
if (!counts.users[username.toLowerCase()].points) { if (!counts.users[username.toLowerCase()].points) {
@ -354,12 +359,8 @@ function addPoints(username, value) {
counts.users[username.toLowerCase()].points = 0; counts.users[username.toLowerCase()].points = 0;
} }
console.log(counts.users[username.toLowerCase()].points);
counts.users[username.toLowerCase()].points += value; counts.users[username.toLowerCase()].points += value;
console.log(counts.users[username.toLowerCase()].points);
localStorage.setItem(`counts`, JSON.stringify(counts)); localStorage.setItem(`counts`, JSON.stringify(counts));
return { return {
@ -688,6 +689,9 @@ function addTask(username, userColor, task) {
tasksFailedToAdd.push(t); tasksFailedToAdd.push(t);
continue; continue;
} }
taskListMemory.totalTaskCount++;
tasks[username].todos.push({ tasks[username].todos.push({
text: t, text: t,
done: false, done: false,
@ -708,9 +712,10 @@ function addTask(username, userColor, task) {
tasksFailedToAdd: tasksFailedToAdd.join('", "') || "", tasksFailedToAdd: tasksFailedToAdd.join('", "') || "",
}, },
}; };
} } else {
tasks[username].todos.push({ text: task, done: false, focus: false }); tasks[username].todos.push({ text: task, done: false, focus: false });
taskListMemory.totalTaskCount++;
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) { if (!scrolling) {
renderTaskListToDOM(); renderTaskListToDOM();
@ -724,6 +729,211 @@ function addTask(username, userColor, task) {
}, },
}; };
} }
}
/**
* This function adds a new task to a user's task list and sets it as the currently focused task.
*
* @param {string} username - The name of the user for whom the task is being added.
* @param {string} userColor - The color associated with the user.
* @param {string} task - The text description of the task to be added.
*
* @returns {Object} - An object containing the status of the operation and a body with either the task added or an error message.
*/
function nowTask(username, userColor, task) {
const tasks = JSON.parse(localStorage.tasks);
if (!tasks[username]) {
tasks[username] = {
todos: [],
done: [],
userColor: userColor,
};
}
if (
incompleteTasksCount(username) >= settings.limit &&
settings.enableLimit
) {
return {
status: 0,
body: {
"error message": `@${username} has reached the limit of ${settings.limit} tasks`,
error: responses.noTaskAdded,
},
};
}
if (
tasks[username].todos.find(
(t) => t.text.toLowerCase() === task.toLowerCase()
)
) {
return {
status: 1,
body: {
"error message": `@${username} already has this task`,
error: responses.duplicateTask,
},
};
}
// if task is whitespace or empty
if (!task || !task.trim()) {
return {
status: 2,
body: {
"error message": `@${username} empty task`,
error: responses.noTaskContent,
},
};
}
// if task is "all", return error
if (task.toLowerCase() === "all") {
return {
status: 2,
body: {
"error message": `@${username} all is a reserved keyword`,
error: responses.noTaskContent,
},
};
}
// if task has commas
if (taskSeparator.some((char) => task.includes(char))) {
// return an error because you can't add multiple tasks with now
return {
status: 2,
body: {
"error message": `@${username} cannot add multiple tasks with now`,
error: responses.noTaskContent,
},
};
}
// set all tasks to unfocused
for (const task of tasks[username].todos) {
task.focus = false;
}
tasks[username].todos.push({ text: task, done: false, focus: true });
taskListMemory.totalTaskCount++;
localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM();
}
return {
status: 200,
body: {
task: task,
},
};
}
/**
* This function adds a new task to a user's task list and sets it as the currently focused task.
*
* @param {string} username - The name of the user for whom the task is being added.
* @param {string} userColor - The color associated with the user.
* @param {string} task - The text description of the task to be added.
*
* @returns {Object} - An object containing the status of the operation and a body with either the task added or an error message.
*/
function nowTask(username, userColor, task) {
const tasks = JSON.parse(localStorage.tasks);
if (!tasks[username]) {
tasks[username] = {
todos: [],
done: [],
userColor: userColor,
};
}
if (
incompleteTasksCount(username) >= settings.limit &&
settings.enableLimit
) {
return {
status: 0,
body: {
"error message": `@${username} has reached the limit of ${settings.limit} tasks`,
error: responses.noTaskAdded,
},
};
}
if (
tasks[username].todos.find(
(t) => t.text.toLowerCase() === task.toLowerCase()
)
) {
return {
status: 1,
body: {
"error message": `@${username} already has this task`,
error: responses.duplicateTask,
},
};
}
// if task is whitespace or empty
if (!task || !task.trim()) {
return {
status: 2,
body: {
"error message": `@${username} empty task`,
error: responses.noTaskContent,
},
};
}
// if task is "all", return error
if (task.toLowerCase() === "all") {
return {
status: 2,
body: {
"error message": `@${username} all is a reserved keyword`,
error: responses.noTaskContent,
},
};
}
// if task has commas
if (taskSeparator.some((char) => task.includes(char))) {
// return an error because you can't add multiple tasks with now
return {
status: 2,
body: {
"error message": `@${username} cannot add multiple tasks with now`,
error: responses.noTaskContent,
},
};
}
// set all tasks to unfocused
for (const task of tasks[username].todos) {
task.focus = false;
}
tasks[username].todos.push({ text: task, done: false, focus: true });
taskListMemory.totalTaskCount++;
localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM();
}
return {
status: 200,
body: {
task: task,
},
};
}
/** /**
* Focuses a specified task for a given user. If the task is successfully focused, the function returns an object with a status of 200 and the focused task. If the task is not focused due to the user having no tasks, the task being invalid input, or the task already being focused, the function returns an object with a status indicating the error and an error message. * Focuses a specified task for a given user. If the task is successfully focused, the function returns an object with a status of 200 and the focused task. If the task is not focused due to the user having no tasks, the task being invalid input, or the task already being focused, the function returns an object with a status indicating the error and an error message.
@ -936,9 +1146,7 @@ function removeTask(username, task) {
if (isInt(t)) { if (isInt(t)) {
index = parseInt(t) - 1; // ACTUAL INDEX index = parseInt(t) - 1; // ACTUAL INDEX
} else if (incompleteTasks.length === 1) { } else if (incompleteTasks.length === 1) {
index = tasks[username].todos.findIndex( index = tasks[username].todos.findIndex((t) => !t.done);
(t) => !t.done
);
tasksRemoved.push(tasks[username].todos[index].text); tasksRemoved.push(tasks[username].todos[index].text);
removedTaskIndex.push(index); removedTaskIndex.push(index);
} else { } else {
@ -975,6 +1183,7 @@ function removeTask(username, task) {
// remove tasks from tasks array // remove tasks from tasks array
for (const index of removedTaskIndex) { for (const index of removedTaskIndex) {
tasks[username].todos.splice(index, 1); tasks[username].todos.splice(index, 1);
taskListMemory.totalTaskCount--;
} }
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
@ -1022,6 +1231,7 @@ function removeTask(username, task) {
task = tasks[username].todos[index].text; task = tasks[username].todos[index].text;
tasks[username].todos.splice(index, 1); tasks[username].todos.splice(index, 1);
taskListMemory.totalTaskCount--;
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
renderTaskListToDOM(); renderTaskListToDOM();
return { return {
@ -1034,6 +1244,134 @@ function removeTask(username, task) {
} }
} }
/**
* This function marks the current task of a user as complete and adds a new task to the user's task list.
*
* @param {string} username - The name of the user who is completing the current task and adding a new one.
* @param {string} task - The text description of the new task to be added.
*
* @returns {Object} - An object containing the status of the operation and a body with either the old and new task or an error message.
*/
function nextTask(username, task) {
const tasks = JSON.parse(localStorage.tasks);
if (!tasks[username] || tasks[username].todos.length === 0) {
return {
status: 0,
body: {
"error message": `@${username} has no tasks`,
error: responses.noTask,
},
};
}
if (task === "") {
return {
status: 1,
body: {
"error message": `@${username} empty task`,
error: responses.nextNoContent,
},
};
}
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
if (incompleteTasks.length !== 1) {
return {
status: 0,
body: {
"error message": `@${username} has more than one incomplete task`,
error: responses.taskNextFailed,
},
};
} else {
// mark the incomplete task as complete, then add a new task "task"
// find index of incomplete task
let index = tasks[username].todos.findIndex((t) => !t.done);
let oldTask = tasks[username].todos[index].text;
// mark task as done
tasks[username].todos[index].done = true;
addDoneCount(username, 1);
// add new task
tasks[username].todos.push({ text: task, done: false, focus: false });
taskListMemory.totalTaskCount++;
localStorage.setItem(`tasks`, JSON.stringify(tasks));
return {
status: 200,
body: {
oldTask: oldTask,
newTask: task,
},
};
}
}
function nextTask(username, task) {
const tasks = JSON.parse(localStorage.tasks);
if (!tasks[username] || tasks[username].todos.length === 0) {
return {
status: 0,
body: {
"error message": `@${username} has no tasks`,
error: responses.noTask,
},
};
}
if (task === "") {
return {
status: 1,
body: {
"error message": `@${username} empty task`,
error: responses.nextNoContent,
},
};
}
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
if (incompleteTasks.length !== 1) {
return {
status: 0,
body: {
"error message": `@${username} has more than one incomplete task`,
error: responses.taskNextFailed,
},
};
} else {
// mark the incomplete task as complete, then add a new task "task"
// find index of incomplete task
let index = tasks[username].todos.findIndex((t) => !t.done);
let oldTask = tasks[username].todos[index].text;
// mark task as done
tasks[username].todos[index].done = true;
addDoneCount(username, 1);
// add new task
tasks[username].todos.push({ text: task, done: false, focus: false });
taskListMemory.totalTaskCount++;
localStorage.setItem(`tasks`, JSON.stringify(tasks));
return {
status: 200,
body: {
oldTask: oldTask,
newTask: task,
},
};
}
}
/** /**
* Determines if a given value is an integer. * Determines if a given value is an integer.
* *
@ -1151,12 +1489,8 @@ function markTaskDone(username, task) {
if (isInt(t)) { if (isInt(t)) {
index = parseInt(t) - 1; // ACTUAL INDEX index = parseInt(t) - 1; // ACTUAL INDEX
} else if (incompleteTasks.length === 1) { } else if (incompleteTasks.length === 1) {
index = tasks[username].todos.findIndex( index = tasks[username].todos.findIndex((t) => !t.done);
(t) => !t.done tasksMarkedComplete.push(tasks[username].todos[index].text);
);
tasksMarkedComplete.push(
tasks[username].todos[index].text
);
// increment count // increment count
addDoneCount(username, 1); addDoneCount(username, 1);
} else { } else {
@ -1171,9 +1505,7 @@ function markTaskDone(username, task) {
tasksFailedToComplete.push(t); tasksFailedToComplete.push(t);
continue; continue;
} else { } else {
tasksMarkedComplete.push( tasksMarkedComplete.push(tasks[username].todos[index].text);
tasks[username].todos[index].text
);
// increment count // increment count
addDoneCount(username, 1); addDoneCount(username, 1);
} }
@ -1226,8 +1558,7 @@ function markTaskDone(username, task) {
} else if (focusedTask) { } else if (focusedTask) {
index = tasks[username].todos.findIndex( index = tasks[username].todos.findIndex(
(t) => (t) =>
t.text.toLowerCase() === t.text.toLowerCase() === focusedTask.text.toLowerCase()
focusedTask.text.toLowerCase()
); );
} else if (settings.automaticDoneIndex) { } else if (settings.automaticDoneIndex) {
// index is the first incomplete task // index is the first incomplete task
@ -1379,9 +1710,7 @@ function markTaskUndone(username, task) {
continue; continue;
} else { } else {
tasksMarkedUndone.push( tasksMarkedUndone.push(tasks[username].todos[index].text);
tasks[username].todos[index].text
);
} }
} else { } else {
tasksMarkedUndone.push(tasks[username].todos[index].text); tasksMarkedUndone.push(tasks[username].todos[index].text);
@ -1760,12 +2089,21 @@ function clearAll() {
}; };
} }
// 200: success /**
function clearAllExceptStreamer(streamer) { * Clears all tasks from the local storage except for those belonging to specified streamer usernames.
* After clearing, it also clears all done tasks, cancels any ongoing animation and re-renders the task list to the DOM.
*
* @param {string[]} streamerUsernames - An array of streamer usernames whose tasks should not be cleared.
* @returns {Object} An object with a status property indicating the success of the operation (200 for success).
*/
function clearAllExceptStreamer(streamerUsername) {
// clear all tasks except for broadcasters // clear all tasks except for broadcasters
const tasks = JSON.parse(localStorage.tasks); const tasks = JSON.parse(localStorage.tasks);
// streamerusernames lowercased
for (const user in tasks) { for (const user in tasks) {
if (user.toLowerCase() !== streamer.toLowerCase()) { if (user.toLowerCase() !== streamerUsername.toLowerCase()) {
tasks[user].todos = []; tasks[user].todos = [];
} }
} }
@ -1783,15 +2121,22 @@ function clearAllExceptStreamer(streamer) {
}; };
} }
const taskListMemory = {
doneTaskCount: 0,
totalTaskCount: 0,
};
function renderTaskListToDOM() { function renderTaskListToDOM() {
const tasks = JSON.parse(localStorage.tasks); const tasks = JSON.parse(localStorage.tasks);
const taskContainers = document.querySelectorAll(".task-container"); const taskContainers = document.querySelectorAll(".task-container");
taskContainers.forEach((taskList) => { taskContainers.forEach((taskList) => {
taskList.innerHTML = ""; taskList.innerHTML = "";
let totalTaskCount = 0; let totalTaskCount = 0;
let completedTasksCount = 0; let completedTasksCount = 0;
for (const user in tasks) { for (const user in tasks) {
const userTasks = tasks[user]; const userTasks = tasks[user];
if (userTasks.todos.length === 0) { if (userTasks.todos.length === 0) {
@ -1840,9 +2185,17 @@ function renderTaskListToDOM() {
} }
} }
if (taskListMemory.doneTaskCount > completedTasksCount) {
completedTasksCount = taskListMemory.doneTaskCount;
totalTaskCount = taskListMemory.totalTaskCount;
}
document.querySelector( document.querySelector(
".task-count" ".task-count"
).innerText = `${completedTasksCount}/${totalTaskCount}`; ).innerText = `${completedTasksCount}/${totalTaskCount}`;
taskListMemory.doneTaskCount = completedTasksCount;
taskListMemory.totalTaskCount = totalTaskCount;
}); });
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
checkToAnimate(); checkToAnimate();