Skip to content

Commit

Permalink
📝 chore(.claspignore): add .gs files to .claspignore to exclude them …
Browse files Browse the repository at this point in the history
…from clasp commands

🐛 fix(Code.ts): move writeMessageLog() call inside the condition to check if SAVE_MESSAGE is true to prevent unnecessary calls

🔀 merge(Code.ts): add SAVE_MESSAGE configuration option to defaultConfig() function to enable/disable saving messages
  • Loading branch information
Plong-Wasin committed Jul 4, 2023
1 parent a0109a7 commit f227a74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .claspignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/*.gs
14 changes: 8 additions & 6 deletions Code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ interface Config {
SAVE_VIDEO: boolean;
SAVE_AUDIO: boolean;
SAVE_FILE: boolean;
SAVE_MESSAGE: boolean;
ALLOW_GET_LINK: boolean;
ALLOW_OVERWRITE: boolean;
COMMAND_GET_LINK: string;
Expand Down Expand Up @@ -119,7 +120,6 @@ function run() {
saveFile();
} else if (messageType === "text" && messageText) {
const userId = getUserId();
writeMessageLog();
if (
getConfigValue("ALLOW_GET_LINK", userId) &&
messageText === getConfigValue("COMMAND_GET_LINK", selectedId)
Expand Down Expand Up @@ -168,6 +168,9 @@ function run() {
);
}
}
if (getConfigValue("SAVE_MESSAGE", selectedId)) {
writeMessageLog();
}
}
}

Expand Down Expand Up @@ -206,11 +209,9 @@ function writeMessageLog() {
// get displayName from userId
const userId = getUserId();
let displayName = "";
for (const row of userSheet
.getRange(2, 1, userSheet.getLastRow(), 1)
.getValues()) {
if (row[0] == userId) {
displayName = row[1];
for (let i = 1; i <= userSheet.getLastRow(); i++) {
if (userSheet.getRange(i, 1).getValue() === userId) {
displayName = userSheet.getRange(i, 2).getValue();
break;
}
}
Expand Down Expand Up @@ -479,6 +480,7 @@ function defaultConfig(): Config {
SAVE_VIDEO: true,
SAVE_AUDIO: true,
SAVE_FILE: true,
SAVE_MESSAGE: true,
ALLOW_GET_LINK: true,
ALLOW_OVERWRITE: true,
COMMAND_GET_LINK: "!link",
Expand Down

0 comments on commit f227a74

Please sign in to comment.