big update: indexedDB, defaultconfigs
This commit is contained in:
parent
4909c87a6f
commit
892674476e
6 changed files with 940 additions and 579 deletions
17
configs.js
17
configs.js
|
|
@ -4,7 +4,7 @@ const configs = (function () {
|
||||||
const settings = {
|
const settings = {
|
||||||
enableLimit: false, // true or false
|
enableLimit: false, // true or false
|
||||||
limit: 10, // integer
|
limit: 10, // integer
|
||||||
automaticDoneIndex: true, // 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
|
||||||
|
|
@ -286,14 +286,7 @@ const configs = (function () {
|
||||||
|
|
||||||
adminResetUsersCount: ["!resetuserscount"],
|
adminResetUsersCount: ["!resetuserscount"],
|
||||||
|
|
||||||
adminClearAllCommands: [
|
adminClearAllCommands: ["!clearallnoregrets"],
|
||||||
"!clearall",
|
|
||||||
"!allclear",
|
|
||||||
"!adminclearall",
|
|
||||||
"!adminallclear",
|
|
||||||
"!aclearall",
|
|
||||||
"!aclear",
|
|
||||||
],
|
|
||||||
|
|
||||||
adminSetBoardCount: ["!setboardcount", "!setallcount"],
|
adminSetBoardCount: ["!setboardcount", "!setallcount"],
|
||||||
additionalCommands: {
|
additionalCommands: {
|
||||||
|
|
@ -331,6 +324,7 @@ const configs = (function () {
|
||||||
"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}!",
|
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",
|
||||||
|
clearedAll: "All tasks and points have been cleared, {user}!",
|
||||||
|
|
||||||
// Grouped by task completion responses
|
// Grouped by task completion responses
|
||||||
taskFinished:
|
taskFinished:
|
||||||
|
|
@ -379,6 +373,11 @@ const configs = (function () {
|
||||||
|
|
||||||
// Help response
|
// 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)
|
||||||
|
|
|
||||||
12
index.html
12
index.html
|
|
@ -1,7 +1,6 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
|
@ -10,15 +9,17 @@
|
||||||
|
|
||||||
<script src="./auth.js"></script>
|
<script src="./auth.js"></script>
|
||||||
<script src="./configs.js"></script>
|
<script src="./configs.js"></script>
|
||||||
|
<script defer src="scripts/functions.js"></script>
|
||||||
|
<script defer src="scripts/defaultConfigs.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>
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="styles/taskList.css" />
|
<link rel="stylesheet" type="text/css" href="styles/taskList.css" />
|
||||||
|
|
||||||
<title>Task List</title>
|
<title>Task List</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div id="main-container">
|
<div id="main-container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="title">!taskhelp</div>
|
<div class="title">!taskhelp</div>
|
||||||
|
|
@ -39,6 +40,5 @@
|
||||||
<div class="task-container secondary"></div>
|
<div class="task-container secondary"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
363
scripts/defaultConfigs.js
Normal file
363
scripts/defaultConfigs.js
Normal file
|
|
@ -0,0 +1,363 @@
|
||||||
|
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
|
||||||
|
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
|
||||||
|
displayTaskCount: true, // true or false
|
||||||
|
};
|
||||||
|
|
||||||
|
// styles
|
||||||
|
const styles = {
|
||||||
|
// task list
|
||||||
|
taskListBackgroundColor: "#000000", // hex only
|
||||||
|
taskListBackgroundOpacity: 0, // 0.0 - 1.0
|
||||||
|
|
||||||
|
taskListBorderWidth: "0px", // px
|
||||||
|
taskListBorderColor: "#ffffff", // hex or name
|
||||||
|
taskListBorderRadius: "0px", // px
|
||||||
|
|
||||||
|
taskListHorizontalPadding: "0px", // px
|
||||||
|
taskListVerticalPadding: "0px", // px
|
||||||
|
|
||||||
|
// header
|
||||||
|
headerHorizontalPadding: "10px", // px
|
||||||
|
headerVerticalPadding: "20px", // px
|
||||||
|
|
||||||
|
headerBackgroundColor: "#000", // hex only
|
||||||
|
headerBackgroundOpacity: 0, // 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
|
||||||
|
|
||||||
|
taskCountMarginRight: "175px", // px
|
||||||
|
|
||||||
|
// body
|
||||||
|
bodyBackgroundColor: "#fff", // hex only
|
||||||
|
bodyBackgroundOpacity: 0, // 0.0 - 1.0
|
||||||
|
|
||||||
|
bodyBorderWidth: "0px", // px
|
||||||
|
bodyBorderColor: "#fff", // hex or name
|
||||||
|
bodyBorderRadius: "5px", // px
|
||||||
|
|
||||||
|
// 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
|
||||||
|
|
||||||
|
taskWidth: "100%",
|
||||||
|
|
||||||
|
taskBackgroundColor: "#000", // hex only
|
||||||
|
taskBackgroundOpacity: 0, // 0.0 - 1.0
|
||||||
|
|
||||||
|
taskFontFamily: "monospace", // font name
|
||||||
|
taskFontSize: "1.5rem", // px
|
||||||
|
taskFontColor: "#fff", // hex or name
|
||||||
|
|
||||||
|
taskBorderColor: "#fff", // hex or name
|
||||||
|
taskBorderWidth: "0px", // px
|
||||||
|
taskBorderRadius: "10px", // px
|
||||||
|
|
||||||
|
taskMarginBottom: "10px", // px
|
||||||
|
taskHorizontalPadding: "20px", // px
|
||||||
|
taskVerticalPadding: "10px", // px
|
||||||
|
|
||||||
|
// done task
|
||||||
|
doneTaskFontColor: "#bbb", // hex or name
|
||||||
|
|
||||||
|
// focus task
|
||||||
|
focusTaskBackgroundColor: "#fff", // hex only
|
||||||
|
focusTaskBackgroundOpacity: 1, // 0.0 - 1.0
|
||||||
|
focusTaskBorderRadius: "5px", // px
|
||||||
|
|
||||||
|
focusTaskFontColor: "#000", // hex or name
|
||||||
|
|
||||||
|
focusTaskHorizontalPadding: "7px", // px
|
||||||
|
focusTaskVerticalPadding: "0px", // px
|
||||||
|
};
|
||||||
|
|
||||||
|
// animation
|
||||||
|
const animation = {
|
||||||
|
scrollSpeed: 50, // px
|
||||||
|
gapBetweenScrolls: 50, // px
|
||||||
|
titles: [
|
||||||
|
"!multitask",
|
||||||
|
"!taskhelp",
|
||||||
|
"!task",
|
||||||
|
"!edit",
|
||||||
|
"!remove",
|
||||||
|
"!done",
|
||||||
|
"!undone",
|
||||||
|
"!botcred",
|
||||||
|
"!count",
|
||||||
|
"!points",
|
||||||
|
"!boardcount",
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const commands = {
|
||||||
|
addTaskCommands: [
|
||||||
|
"!taska",
|
||||||
|
"!taskadd",
|
||||||
|
"!atask",
|
||||||
|
"!addtask",
|
||||||
|
"!task",
|
||||||
|
"!add",
|
||||||
|
"!todo",
|
||||||
|
"!a",
|
||||||
|
],
|
||||||
|
editTaskCommands: [
|
||||||
|
"!taske",
|
||||||
|
"!taskedit",
|
||||||
|
"!etask",
|
||||||
|
"!edittask",
|
||||||
|
"!edit",
|
||||||
|
"!e",
|
||||||
|
],
|
||||||
|
deleteTaskCommands: [
|
||||||
|
"!taskdel",
|
||||||
|
"!taskdelete",
|
||||||
|
"!deltask",
|
||||||
|
"!deletetask",
|
||||||
|
"!taskr",
|
||||||
|
"!taskremove",
|
||||||
|
"!rtask",
|
||||||
|
"!removetask",
|
||||||
|
"!remove",
|
||||||
|
"!delete",
|
||||||
|
"!r",
|
||||||
|
],
|
||||||
|
finishTaskCommands: [
|
||||||
|
"!taskf",
|
||||||
|
"!taskfinish",
|
||||||
|
"!ftask",
|
||||||
|
"!finishtask",
|
||||||
|
"!taskd",
|
||||||
|
"!taskdone",
|
||||||
|
"!donetask",
|
||||||
|
"!dtask",
|
||||||
|
"!finish",
|
||||||
|
"!done",
|
||||||
|
"!finished",
|
||||||
|
"!f",
|
||||||
|
],
|
||||||
|
unfinishTaskCommands: [
|
||||||
|
"!tasku",
|
||||||
|
"!taskunfinish",
|
||||||
|
"!utask",
|
||||||
|
"!unfinishtask",
|
||||||
|
"!taskud",
|
||||||
|
"!taskundone",
|
||||||
|
"!undonetask",
|
||||||
|
"!undone",
|
||||||
|
"!unfinish",
|
||||||
|
"!unfinished",
|
||||||
|
"!u",
|
||||||
|
],
|
||||||
|
nextTaskCommands: [
|
||||||
|
"!taskn",
|
||||||
|
"!tasknext",
|
||||||
|
"!ntask",
|
||||||
|
"!nexttask",
|
||||||
|
"!next",
|
||||||
|
"!n",
|
||||||
|
],
|
||||||
|
focusTaskCommands: ["!focus", "!taskfocus", "!focustask"],
|
||||||
|
unfocusTaskCommands: ["!unfocus", "!taskunfocus", "!unfocustask"],
|
||||||
|
nowTaskCommands: ["!now", "!tasknow", "!nowtask"],
|
||||||
|
helpCommands: [
|
||||||
|
"!taskh",
|
||||||
|
"!taskhelp",
|
||||||
|
"!htask",
|
||||||
|
"!helptask",
|
||||||
|
"!tasks",
|
||||||
|
"!help",
|
||||||
|
],
|
||||||
|
checkCommands: [
|
||||||
|
"!taskc",
|
||||||
|
"!taskcheck",
|
||||||
|
"!ctask",
|
||||||
|
"!checktask",
|
||||||
|
"!mytask",
|
||||||
|
"!check",
|
||||||
|
"!mytasks",
|
||||||
|
],
|
||||||
|
listCommands: ["!taskl", "!tasklist", "!listtasks", "!list"],
|
||||||
|
clearMyDoneCommands: ["!clearmydone"],
|
||||||
|
checkCountCommands: ["!taskcount", "!count", "!checkcount", "!mycount"],
|
||||||
|
checkAllCountCommands: [
|
||||||
|
"!taskallcount",
|
||||||
|
"!allcount",
|
||||||
|
"!checkallcount",
|
||||||
|
"!boardcount",
|
||||||
|
"!checkboardcount",
|
||||||
|
"!taskboardcount",
|
||||||
|
],
|
||||||
|
checkMyPointsCommands: [
|
||||||
|
"!taskpoints",
|
||||||
|
"!points",
|
||||||
|
"!mypoints",
|
||||||
|
"!checkpoints",
|
||||||
|
],
|
||||||
|
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"],
|
||||||
|
adminClearNotStreamerCommands: [
|
||||||
|
"!clearnotstreamer",
|
||||||
|
"!aclearnotstreamer",
|
||||||
|
"!adminclearnotstreamer",
|
||||||
|
"!clearns",
|
||||||
|
],
|
||||||
|
adminClearDoneCommands: [
|
||||||
|
"!acleardone",
|
||||||
|
"!admincleardone",
|
||||||
|
"!cleardone",
|
||||||
|
],
|
||||||
|
adminClearAllCommands: ["!clearallnoregrets"],
|
||||||
|
adminClearTasksCommands: ["!cleartasks", "!clearalltasks", "!clearall"],
|
||||||
|
adminSetBoardCount: ["!setboardcount", "!setallcount"],
|
||||||
|
adminResetBoardCount: ["!resetboardcount", "!resetallcount"],
|
||||||
|
adminResetUsersCount: ["!resetuserscount"],
|
||||||
|
adminBackupCommands: ["!backup", "!backupdata", "!setbackup"],
|
||||||
|
adminLoadBackupCommands: [
|
||||||
|
"!loadbackup",
|
||||||
|
"!loaddata",
|
||||||
|
"!loadbackupdata",
|
||||||
|
],
|
||||||
|
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
|
||||||
|
taskAdded: 'The task(s) "{task}" has been added, {user}!',
|
||||||
|
noTaskAdded:
|
||||||
|
"Looks like you already hit the limit of incomplete tasks, {user}",
|
||||||
|
noTaskContent: "Try using !task the-task-you-are-working-on {user}",
|
||||||
|
duplicateTask:
|
||||||
|
"Looks like you already have the task '{message}' up there {user}!",
|
||||||
|
taskEdited:
|
||||||
|
'Task "{originalTask}" has been edited to "{task}" successfully, {user}',
|
||||||
|
noTaskEdit: "Try doing !edit [index] [new task] {user}",
|
||||||
|
nowTask: 'Task "{task}" is now the task you are working on, {user}!',
|
||||||
|
|
||||||
|
// Grouped by task progression responses
|
||||||
|
taskNext:
|
||||||
|
"Good job on finishing the task '{oldTask}'! Now moving onto '{newTask}', {user}!",
|
||||||
|
nextNoContent: "Try using !next the-task-you-want-to-do-next {user}",
|
||||||
|
taskNextFailed:
|
||||||
|
"Unable to perform command with multiple incomplete tasks, {user}!",
|
||||||
|
|
||||||
|
// Grouped by task deletion responses
|
||||||
|
clearedMyDone: "All of your completed tasks have been cleared, {user}!",
|
||||||
|
taskDeleted: 'Task(s) "{task}" has been deleted successfully, {user}',
|
||||||
|
specifyTaskIndex:
|
||||||
|
"Try specifying the index of the incomplete task(s) {user}",
|
||||||
|
clearTasksExceptBroadcaster:
|
||||||
|
"All tasks have been cleared except for the streamer's, {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}!",
|
||||||
|
|
||||||
|
// Grouped by task completion responses
|
||||||
|
taskFinished:
|
||||||
|
'Good job on finishing the task(s) "{task}", {user}! You have earned {pointCount} {pointName} and completed {doneCount} task(s) so far!',
|
||||||
|
allTasksFinished:
|
||||||
|
"Good job on finishing all your tasks, {user}! You have completed {doneCount} task(s) so far!",
|
||||||
|
taskUnfinished: 'Task(s) "{task}" has been unmarked as done, {user}!',
|
||||||
|
taskAlreadyFinished: "Looks like you already finished that task {user}",
|
||||||
|
|
||||||
|
// Grouped by task focus responses
|
||||||
|
clearFocused: "Task has been unfocused, {user}!",
|
||||||
|
noFocusedTask: "Looks like you don't have a focused task {user}!",
|
||||||
|
alreadyFocusedTask:
|
||||||
|
"Looks like you already have that task set to focus {user}!",
|
||||||
|
onlyOneFocus: "You can only focus one task at a time {user}!",
|
||||||
|
specifyFocusTask: "Try specifying an incomplete task to focus {user}!",
|
||||||
|
taskFocused: 'Task "{task}" has been focused, {user}!',
|
||||||
|
|
||||||
|
// Grouped by task existence responses
|
||||||
|
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!",
|
||||||
|
|
||||||
|
// backup-related responses
|
||||||
|
backupStorage: "Data has been backed up, {user}!",
|
||||||
|
loadBackup: "Data has been loaded, {user}!",
|
||||||
|
|
||||||
|
// Grouped by permission-related responses
|
||||||
|
notMod: "Permission denied, {user}; Mods only",
|
||||||
|
notStreamer: "Permission denied, {user}; Streamer only",
|
||||||
|
|
||||||
|
// Grouped by help-related responses
|
||||||
|
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 {
|
||||||
|
StreamerUsernames,
|
||||||
|
settings,
|
||||||
|
styles,
|
||||||
|
animation,
|
||||||
|
commands,
|
||||||
|
responses,
|
||||||
|
};
|
||||||
|
})();
|
||||||
12
scripts/functions.js
Normal file
12
scripts/functions.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
function getResponse(responseName) {
|
||||||
|
return (
|
||||||
|
configs.responses[responseName] ??
|
||||||
|
defaultConfigs.responses[responseName]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCommand(commandName) {
|
||||||
|
return (
|
||||||
|
configs.commands[commandName] ?? defaultConfigs.commands[commandName]
|
||||||
|
);
|
||||||
|
}
|
||||||
204
scripts/index.js
204
scripts/index.js
|
|
@ -18,7 +18,7 @@ function isStreamer(flags) {
|
||||||
return flags.broadcaster;
|
return flags.broadcaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
function processCommand(user, command, message, flags, extra) {
|
async function processCommand(user, command, message, flags, extra) {
|
||||||
params = {
|
params = {
|
||||||
user: user,
|
user: user,
|
||||||
message: message,
|
message: message,
|
||||||
|
|
@ -26,14 +26,14 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (commands.addTaskCommands.includes(command)) {
|
if (commands.addTaskCommands.includes(command)) {
|
||||||
let addRequest = addTask(user, extra.userColor, message);
|
let addRequest = await addTask(user, extra.userColor, message);
|
||||||
|
|
||||||
if (addRequest.status !== 200) {
|
if (addRequest.status !== 200) {
|
||||||
respond(addRequest.body.error, params);
|
respond(addRequest.body.error, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let addedResponse = responses.taskAdded;
|
let addedResponse = getResponse("taskAdded");
|
||||||
params.task = addRequest.body.task;
|
params.task = addRequest.body.task;
|
||||||
|
|
||||||
if (addRequest.body.tasksFailedToAdd !== "") {
|
if (addRequest.body.tasksFailedToAdd !== "") {
|
||||||
|
|
@ -42,7 +42,7 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
|
|
||||||
respond(addedResponse, params);
|
respond(addedResponse, params);
|
||||||
} else if (commands.editTaskCommands.includes(command)) {
|
} else if (commands.editTaskCommands.includes(command)) {
|
||||||
let editRequest = editTask(user, message);
|
let editRequest = await editTask(user, message);
|
||||||
|
|
||||||
if (editRequest.status !== 200) {
|
if (editRequest.status !== 200) {
|
||||||
respond(editRequest.body.error, params);
|
respond(editRequest.body.error, params);
|
||||||
|
|
@ -55,15 +55,15 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
params.task = newTask;
|
params.task = newTask;
|
||||||
params.originalTask = originalTask;
|
params.originalTask = originalTask;
|
||||||
|
|
||||||
respond(responses.taskEdited, params);
|
respond(getResponse("taskEdited"), params);
|
||||||
} else if (commands.deleteTaskCommands.includes(command)) {
|
} else if (commands.deleteTaskCommands.includes(command)) {
|
||||||
let removeRequest = removeTask(user, message);
|
let removeRequest = await removeTask(user, message);
|
||||||
|
|
||||||
if (removeRequest.status !== 200) {
|
if (removeRequest.status !== 200) {
|
||||||
respond(removeRequest.body.error, params);
|
respond(removeRequest.body.error, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let deletedResponse = responses.taskDeleted;
|
let deletedResponse = getResponse("taskDeleted");
|
||||||
|
|
||||||
let removedTasks = removeRequest.body.removedTasks;
|
let removedTasks = removeRequest.body.removedTasks;
|
||||||
let failedTasks = removeRequest.body.failedTasks;
|
let failedTasks = removeRequest.body.failedTasks;
|
||||||
|
|
@ -77,31 +77,31 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
respond(deletedResponse, params);
|
respond(deletedResponse, params);
|
||||||
} else if (commands.finishTaskCommands.includes(command)) {
|
} else if (commands.finishTaskCommands.includes(command)) {
|
||||||
if (message === "all") {
|
if (message === "all") {
|
||||||
let finishAllRequest = markAllTasksAsDone(user);
|
let finishAllRequest = await markAllTasksAsDone(user);
|
||||||
|
|
||||||
if (finishAllRequest.status !== 200) {
|
if (finishAllRequest.status !== 200) {
|
||||||
respond(finishAllRequest.body.error, params);
|
respond(finishAllRequest.body.error, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let finishedAllResponse = responses.allTasksFinished;
|
let finishedAllResponse = getResponse("allTasksFinished");
|
||||||
params.doneCount = completedTasksCount(user);
|
params.doneCount = await completedTasksCount(user);
|
||||||
|
|
||||||
respond(finishedAllResponse, params);
|
respond(finishedAllResponse, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let finishRequest = markTaskDone(user, message);
|
let finishRequest = await markTaskDone(user, message);
|
||||||
|
|
||||||
if (finishRequest.status !== 200) {
|
if (finishRequest.status !== 200) {
|
||||||
respond(finishRequest.body.error, params);
|
respond(finishRequest.body.error, params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let finishedResponse = responses.taskFinished;
|
let finishedResponse = getResponse("taskFinished");
|
||||||
|
|
||||||
params.task = finishRequest.body.markedTasks;
|
params.task = finishRequest.body.markedTasks;
|
||||||
params.doneCount = completedTasksCount(user);
|
params.doneCount = await completedTasksCount(user);
|
||||||
params.pointCount =
|
params.pointCount =
|
||||||
finishRequest.body.markedTasksCount *
|
finishRequest.body.markedTasksCount *
|
||||||
configs.settings.pointsPerTask;
|
configs.settings.pointsPerTask;
|
||||||
|
|
@ -112,7 +112,7 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
|
|
||||||
respond(finishedResponse, params);
|
respond(finishedResponse, params);
|
||||||
} else if (commands.unfinishTaskCommands.includes(command)) {
|
} else if (commands.unfinishTaskCommands.includes(command)) {
|
||||||
let unfinishRequest = markTaskUndone(user, message);
|
let unfinishRequest = await markTaskUndone(user, message);
|
||||||
|
|
||||||
if (unfinishRequest.status !== 200) {
|
if (unfinishRequest.status !== 200) {
|
||||||
respond(unfinishRequest.body.error, params);
|
respond(unfinishRequest.body.error, params);
|
||||||
|
|
@ -120,7 +120,7 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// task unfinished
|
// task unfinished
|
||||||
let unfinishedResponse = responses.taskUnfinished;
|
let unfinishedResponse = getResponse("taskUnfinished");
|
||||||
|
|
||||||
params.task = unfinishRequest.body.markedTasks;
|
params.task = unfinishRequest.body.markedTasks;
|
||||||
|
|
||||||
|
|
@ -130,7 +130,7 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
|
|
||||||
respond(unfinishedResponse, params);
|
respond(unfinishedResponse, params);
|
||||||
} else if (commands.nextTaskCommands.includes(command)) {
|
} else if (commands.nextTaskCommands.includes(command)) {
|
||||||
let nextRequest = nextTask(user, message);
|
let nextRequest = await nextTask(user, message);
|
||||||
|
|
||||||
if (nextRequest.status !== 200) {
|
if (nextRequest.status !== 200) {
|
||||||
respond(nextRequest.body.error, params);
|
respond(nextRequest.body.error, params);
|
||||||
|
|
@ -138,14 +138,14 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// task next
|
// task next
|
||||||
let nextResponse = responses.taskNext;
|
let nextResponse = getResponse("taskNext");
|
||||||
|
|
||||||
params.oldTask = nextRequest.body.oldTask;
|
params.oldTask = nextRequest.body.oldTask;
|
||||||
params.newTask = nextRequest.body.newTask;
|
params.newTask = nextRequest.body.newTask;
|
||||||
|
|
||||||
respond(nextResponse, params);
|
respond(nextResponse, params);
|
||||||
} else if (commands.nowTaskCommands.includes(command)) {
|
} else if (commands.nowTaskCommands.includes(command)) {
|
||||||
let nowRequest = nowTask(user, extra.userColor, message);
|
let nowRequest = await nowTask(user, extra.userColor, message);
|
||||||
|
|
||||||
if (nowRequest.status !== 200) {
|
if (nowRequest.status !== 200) {
|
||||||
respond(nowRequest.body.error, params);
|
respond(nowRequest.body.error, params);
|
||||||
|
|
@ -153,13 +153,13 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// task now
|
// task now
|
||||||
let nowResponse = responses.nowTask;
|
let nowResponse = getResponse("nowTask");
|
||||||
|
|
||||||
params.task = nowRequest.body.task;
|
params.task = nowRequest.body.task;
|
||||||
|
|
||||||
respond(nowResponse, params);
|
respond(nowResponse, params);
|
||||||
} else if (commands.focusTaskCommands.includes(command)) {
|
} else if (commands.focusTaskCommands.includes(command)) {
|
||||||
let focusRequest = focusTask(user, message);
|
let focusRequest = await focusTask(user, message);
|
||||||
|
|
||||||
if (focusRequest.status !== 200) {
|
if (focusRequest.status !== 200) {
|
||||||
respond(focusRequest.body.error, params);
|
respond(focusRequest.body.error, params);
|
||||||
|
|
@ -167,13 +167,13 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// task focused
|
// task focused
|
||||||
let focusedResponse = responses.taskFocused;
|
let focusedResponse = getResponse("taskFocused");
|
||||||
|
|
||||||
params.task = focusRequest.body.focusedTask;
|
params.task = focusRequest.body.focusedTask;
|
||||||
|
|
||||||
respond(focusedResponse, params);
|
respond(focusedResponse, params);
|
||||||
} else if (commands.unfocusTaskCommands.includes(command)) {
|
} else if (commands.unfocusTaskCommands.includes(command)) {
|
||||||
let unfocusRequest = unfocusTask(user);
|
let unfocusRequest = await unfocusTask(user);
|
||||||
|
|
||||||
if (unfocusRequest.status !== 200) {
|
if (unfocusRequest.status !== 200) {
|
||||||
respond(unfocusRequest.body.error, params);
|
respond(unfocusRequest.body.error, params);
|
||||||
|
|
@ -181,12 +181,12 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// task unfocused
|
// task unfocused
|
||||||
let unfocusedResponse = responses.clearFocused;
|
let unfocusedResponse = getResponse("clearFocused");
|
||||||
|
|
||||||
respond(unfocusedResponse, params);
|
respond(unfocusedResponse, params);
|
||||||
} else if (commands.checkCommands.includes(command)) {
|
} else if (commands.checkCommands.includes(command)) {
|
||||||
if (message === "") {
|
if (message === "") {
|
||||||
let checkRequest = checkTasks(user);
|
let checkRequest = await checkTasks(user);
|
||||||
if (checkRequest.status !== 200) {
|
if (checkRequest.status !== 200) {
|
||||||
// no tasks
|
// no tasks
|
||||||
respond(checkRequest.body.error, params);
|
respond(checkRequest.body.error, params);
|
||||||
|
|
@ -196,7 +196,7 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
return respond(checkRequest.body.reply, params);
|
return respond(checkRequest.body.reply, params);
|
||||||
} else {
|
} else {
|
||||||
let mentioned = message.replace("@", "");
|
let mentioned = message.replace("@", "");
|
||||||
let checkRequest = checkTasks(mentioned);
|
let checkRequest = await checkTasks(mentioned);
|
||||||
|
|
||||||
if (checkRequest.status !== 200) {
|
if (checkRequest.status !== 200) {
|
||||||
// no tasks
|
// no tasks
|
||||||
|
|
@ -208,74 +208,76 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
}
|
}
|
||||||
} else if (commands.adminDeleteCommands.includes(command)) {
|
} else if (commands.adminDeleteCommands.includes(command)) {
|
||||||
if (!isMod(flags)) {
|
if (!isMod(flags)) {
|
||||||
respond(responses.notMod, params);
|
respond(getResponse("notMod"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let mentioned = message.replace("@", "");
|
let mentioned = message.replace("@", "");
|
||||||
|
|
||||||
if (mentioned === "") {
|
if (mentioned === "") {
|
||||||
respond(responses.specifyUser, params);
|
respond(getResponse("specifyUser"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let clearUserTaskResponse = clearUserTasks(mentioned);
|
let clearUserTaskResponse = await clearUserTasks(mentioned);
|
||||||
|
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
|
|
||||||
if (clearUserTaskResponse.status === 0) {
|
if (clearUserTaskResponse.status === 0) {
|
||||||
// no tasks
|
// no tasks
|
||||||
respond(responses.noTaskA, params);
|
respond(getResponse("noTaskA"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
respond(responses.adminDeleteTasks, params);
|
respond(getResponse("adminDeleteTasks"), params);
|
||||||
return;
|
return;
|
||||||
} else if (commands.adminClearDoneCommands.includes(command)) {
|
} else if (commands.adminClearDoneCommands.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAllDoneTasks();
|
clearAllDoneTasks();
|
||||||
respond(responses.clearedDone, params);
|
respond(getResponse("clearedDone"), params);
|
||||||
return;
|
return;
|
||||||
} else if (commands.adminClearAllCommands.includes(command)) {
|
} else if (commands.adminClearAllCommands.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
clearAll();
|
clearAll();
|
||||||
respond(responses.clearedAll, params);
|
respond(getResponse("clearedAll"), params);
|
||||||
return;
|
return;
|
||||||
} else if (commands.clearMyDoneCommands.includes(command)) {
|
} else if (commands.clearMyDoneCommands.includes(command)) {
|
||||||
let clearOwnDoneResponse = clearOwnDoneTasks(user);
|
let clearOwnDoneResponse = await clearOwnDoneTasks(user);
|
||||||
|
|
||||||
if (clearOwnDoneResponse.status !== 200) {
|
if (clearOwnDoneResponse.status !== 200) {
|
||||||
// no tasks
|
// no tasks
|
||||||
respond(responses.noTask, params);
|
respond(getResponse("noTask"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
respond(responses.clearedMyDone, params);
|
respond(getResponse("clearedMyDone"), params);
|
||||||
} else if (commands.adminClearNotStreamerCommands.includes(command)) {
|
} else if (commands.adminClearNotStreamerCommands.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await clearMemory();
|
||||||
|
|
||||||
clearAllExceptStreamer(auth.channel);
|
await clearAllExceptStreamer(configs.StreamerUsernames);
|
||||||
respond(responses.clearTasksExceptBroadcaster, params);
|
respond(getResponse("clearTasksExceptBroadcaster"), params);
|
||||||
} else if (commands.adminClearTasksCommands.includes(command)) {
|
} else if (commands.adminClearTasksCommands.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await clearMemory();
|
||||||
|
|
||||||
clearAllTasks();
|
await clearAllTasks();
|
||||||
respond(responses.clearedTasks, params);
|
respond(getResponse("clearedTasks"), params);
|
||||||
} else if (commands.listCommands.includes(command)) {
|
} else if (commands.listCommands.includes(command)) {
|
||||||
let listTaskResponse = listTasks(user);
|
let listTaskResponse = await listTasks(user);
|
||||||
|
|
||||||
if (listTaskResponse.status !== 200) {
|
if (listTaskResponse.status !== 200) {
|
||||||
// no tasks
|
// no tasks
|
||||||
|
|
@ -286,187 +288,187 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
respond(listTaskResponse.body.reply, params);
|
respond(listTaskResponse.body.reply, params);
|
||||||
} else if (commands.checkCountCommands.includes(command)) {
|
} else if (commands.checkCountCommands.includes(command)) {
|
||||||
if (message === "") {
|
if (message === "") {
|
||||||
let count = completedTasksCount(user);
|
let count = await completedTasksCount(user);
|
||||||
|
|
||||||
params.doneCount = count;
|
params.doneCount = count;
|
||||||
|
|
||||||
return respond(responses.checkYourCount, params);
|
return respond(getResponse("checkYourCount"), params);
|
||||||
} else {
|
} else {
|
||||||
let mentioned = message.replace("@", "");
|
let mentioned = message.replace("@", "");
|
||||||
let count = completedTasksCount(mentioned);
|
let count = await completedTasksCount(mentioned);
|
||||||
|
|
||||||
params.doneCount = count;
|
params.doneCount = count;
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
|
|
||||||
return respond(responses.checkUserCount, params);
|
return respond(getResponse("checkUserCount"), params);
|
||||||
}
|
}
|
||||||
} else if (commands.checkAllCountCommands.includes(command)) {
|
} else if (commands.checkAllCountCommands.includes(command)) {
|
||||||
let count = getBoardTotalTaskCount();
|
let count = getBoardTotalTaskCount();
|
||||||
|
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
respond(responses.noCountAll, params);
|
respond(getResponse("noCountAll"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
params.doneCount = count;
|
params.doneCount = count;
|
||||||
|
|
||||||
respond(responses.checkAllCount, params);
|
respond(getResponse("checkAllCount"), params);
|
||||||
} else if (commands.checkMyPointsCommands.includes(command)) {
|
} else if (commands.checkMyPointsCommands.includes(command)) {
|
||||||
if (message === "") {
|
if (message === "") {
|
||||||
let points = getUserPoints(user);
|
let points = await getUserPoints(user);
|
||||||
|
|
||||||
params.pointCount = points;
|
params.pointCount = points;
|
||||||
|
|
||||||
return respond(responses.checkMyPoints, params);
|
return respond(getResponse("checkMyPoints"), params);
|
||||||
} else {
|
} else {
|
||||||
let mentioned = message.replace("@", "");
|
let mentioned = message.replace("@", "");
|
||||||
let points = getUserPoints(mentioned);
|
let points = await getUserPoints(mentioned);
|
||||||
|
|
||||||
params.pointCount = points;
|
params.pointCount = points;
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
|
|
||||||
return respond(responses.checkUserPoints, params);
|
return respond(getResponse("checkUserPoints"), params);
|
||||||
}
|
}
|
||||||
} else if (commands.syncCountPointsCommands.includes(command)) {
|
} else if (commands.syncCountPointsCommands.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
syncPointsToCount();
|
await syncPointsToCount();
|
||||||
respond(responses.syncCountPoints, params);
|
respond(getResponse("syncCountPoints"), params);
|
||||||
} else if (commands.addPointsCommands.includes(command)) {
|
} else if (commands.addPointsCommands.includes(command)) {
|
||||||
// !addpoints @user 100
|
// !addpoints @user 100
|
||||||
|
|
||||||
if (!isMod(flags)) {
|
if (!isMod(flags)) {
|
||||||
respond(responses.notMod, params);
|
respond(getResponse("notMod"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentioned = message.split(" ")[0].replace("@", "");
|
let mentioned = message.split(" ")[0].replace("@", "");
|
||||||
|
|
||||||
if (mentioned === "") {
|
if (mentioned === "") {
|
||||||
respond(responses.specifyUser, params);
|
respond(getResponse("specifyUser"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let points = message.split(" ")[1];
|
let points = message.split(" ")[1];
|
||||||
|
|
||||||
if (points === undefined) {
|
if (points === undefined) {
|
||||||
respond(responses.specifyPoints, params);
|
respond(getResponse("specifyPoints"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^\d+$/.test(points)) {
|
if (!/^\d+$/.test(points)) {
|
||||||
respond(responses.invalidNumber, params);
|
respond(getResponse("invalidNumber"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
points = parseInt(points);
|
points = parseInt(points);
|
||||||
|
|
||||||
addPoints(mentioned, points);
|
await addPoints(mentioned, points);
|
||||||
|
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
params.pointCount = points;
|
params.pointCount = points;
|
||||||
|
|
||||||
respond(responses.addPoints, params);
|
respond(getResponse("addPoints"), params);
|
||||||
} else if (commands.reducePointsCommands.includes(command)) {
|
} else if (commands.reducePointsCommands.includes(command)) {
|
||||||
if (!isMod(flags)) {
|
if (!isMod(flags)) {
|
||||||
respond(responses.notMod, params);
|
respond(getResponse("notMod"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentioned = message.split(" ")[0].replace("@", "");
|
let mentioned = message.split(" ")[0].replace("@", "");
|
||||||
|
|
||||||
if (mentioned === "") {
|
if (mentioned === "") {
|
||||||
respond(responses.specifyUser, params);
|
respond(getResponse("specifyUser"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let points = message.split(" ")[1];
|
let points = message.split(" ")[1];
|
||||||
|
|
||||||
if (points === undefined) {
|
if (points == undefined) {
|
||||||
respond(responses.specifyPoints, params);
|
respond(getResponse("specifyPoints"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^\d+$/.test(points)) {
|
if (!/^\d+$/.test(points)) {
|
||||||
respond(responses.invalidNumber, params);
|
respond(getResponse("invalidNumber"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
reducePoints(mentioned, points);
|
await reducePoints(mentioned, points);
|
||||||
|
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
params.pointCount = points;
|
params.pointCount = points;
|
||||||
|
|
||||||
respond(responses.reducePoints, params);
|
respond(getResponse("reducePoints"), params);
|
||||||
} else if (commands.setUserPointsCommands.includes(command)) {
|
} else if (commands.setUserPointsCommands.includes(command)) {
|
||||||
if (!isMod(flags)) {
|
if (!isMod(flags)) {
|
||||||
respond(responses.notMod, params);
|
respond(getResponse("notMod"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentioned = message.split(" ")[0].replace("@", "");
|
let mentioned = message.split(" ")[0].replace("@", "");
|
||||||
|
|
||||||
if (mentioned === "") {
|
if (mentioned === "") {
|
||||||
respond(responses.specifyUser, params);
|
respond(getResponse("specifyUser"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let points = message.split(" ")[1];
|
let points = message.split(" ")[1];
|
||||||
|
|
||||||
if (points === undefined) {
|
if (points === undefined) {
|
||||||
respond(responses.specifyPoints, params);
|
respond(getResponse("specifyPoints"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^\d+$/.test(points)) {
|
if (!/^\d+$/.test(points)) {
|
||||||
respond(responses.invalidNumber, params);
|
respond(getResponse("invalidNumber"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
points = parseInt(points);
|
points = parseInt(points);
|
||||||
|
|
||||||
setUserPoints(mentioned, points);
|
await setUserPoints(mentioned, points);
|
||||||
|
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
params.pointCount = points;
|
params.pointCount = points;
|
||||||
|
|
||||||
respond(responses.setUserPoints, params);
|
respond(getResponse("setUserPoints"), params);
|
||||||
} else if (commands.setUserTaskCountCommands.includes(commands)) {
|
} else if (commands.setUserTaskCountCommands.includes(commands)) {
|
||||||
if (!isMod(flags)) {
|
if (!isMod(flags)) {
|
||||||
respond(responses.notMod, params);
|
respond(getResponse("notMod"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mentioned = message.split(" ")[0].replace("@", "");
|
let mentioned = message.split(" ")[0].replace("@", "");
|
||||||
|
|
||||||
if (mentioned === "") {
|
if (mentioned === "") {
|
||||||
respond(responses.specifyUser, params);
|
respond(getResponse("specifyUser"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let count = message.split(" ")[1];
|
let count = message.split(" ")[1];
|
||||||
|
|
||||||
if (count === undefined) {
|
if (count === undefined) {
|
||||||
respond(responses.specifyCount, params);
|
respond(getResponse("specifyCount"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!/^\d+$/.test(count)) {
|
if (!/^\d+$/.test(count)) {
|
||||||
respond(responses.invalidNumber, params);
|
respond(getResponse("invalidNumber"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
points = parseInt(points);
|
points = parseInt(points);
|
||||||
|
|
||||||
setUserTaskCount(mentioned, count);
|
await setUserTaskCount(mentioned, count);
|
||||||
|
|
||||||
params.mentioned = mentioned;
|
params.mentioned = mentioned;
|
||||||
params.pointCount = count;
|
params.pointCount = count;
|
||||||
|
|
||||||
respond(responses.setUserTaskCount, params);
|
respond(getResponse("setUserTaskCount"), params);
|
||||||
} else if (commands.leaderboardCommands.includes(command)) {
|
} else if (commands.leaderboardCommands.includes(command)) {
|
||||||
let leaderboardResponse = leaderboardTaskCount(5);
|
let leaderboardResponse = leaderboardTaskCount(5);
|
||||||
|
|
||||||
|
|
@ -480,39 +482,55 @@ function processCommand(user, command, message, flags, extra) {
|
||||||
respond(leaderboard, params);
|
respond(leaderboard, params);
|
||||||
} else if (commands.adminSetBoardCount.includes(command)) {
|
} else if (commands.adminSetBoardCount.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if message is a number using regex
|
// check if message is a number using regex
|
||||||
if (!/^\d+$/.test(message)) {
|
if (!/^\d+$/.test(message)) {
|
||||||
respond(responses.invalidNumber, params);
|
respond(getResponse("invalidNumber"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
params.count = message;
|
params.count = message;
|
||||||
|
|
||||||
setTotalCompleteCount(message);
|
await setTotalCompleteCount(message);
|
||||||
|
|
||||||
respond(responses.setBoardCount, params);
|
respond(getResponse("setBoardCount"), params);
|
||||||
} else if (commands.adminResetBoardCount.includes(command)) {
|
} else if (commands.adminResetBoardCount.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetBoardCount();
|
await resetBoardCount();
|
||||||
respond(responses.clearedBoardCount, params);
|
respond(getResponse("clearedBoardCount"), params);
|
||||||
} else if (commands.adminResetUsersCount.includes(command)) {
|
} else if (commands.adminResetUsersCount.includes(command)) {
|
||||||
if (!isStreamer(flags)) {
|
if (!isStreamer(flags)) {
|
||||||
respond(responses.notStreamer, params);
|
respond(getResponse("notStreamer"), params);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
resetUsersCount();
|
await resetUsersCount();
|
||||||
respond(responses.clearedUsersCount, params);
|
respond(getResponse("clearedUsersCount"), params);
|
||||||
} else if (commands.helpCommands.includes(command)) {
|
} else if (commands.helpCommands.includes(command)) {
|
||||||
respond(responses.help, params);
|
respond(getResponse("help"), params);
|
||||||
|
} else if (command === "!clearlocalstorage") {
|
||||||
|
if (!isStreamer(flags)) {
|
||||||
|
respond(getResponse("notStreamer"), params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearLocalStorage();
|
||||||
|
|
||||||
|
respond(getResponse("clearLocalStorage"), params);
|
||||||
|
} else if (["!transferdata"].includes(command)) {
|
||||||
|
if (!isStreamer(flags)) {
|
||||||
|
respond(getResponse("notStreamer"), params);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await transferLocalStorageToIndexedDB();
|
||||||
} else if (commands.additionalCommands[command]) {
|
} else if (commands.additionalCommands[command]) {
|
||||||
respond(commands.additionalCommands[command], params);
|
respond(commands.additionalCommands[command], params);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue